Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-zastd= infinite loop with unknown value #1371

Closed
fuhsnn opened this issue Jan 7, 2025 · 3 comments
Closed

-zastd= infinite loop with unknown value #1371

fuhsnn opened this issue Jan 7, 2025 · 3 comments
Labels
bug C C compiler

Comments

@fuhsnn
Copy link

fuhsnn commented Jan 7, 2025

Passing options like -zastd=c11 -zastd=c++03 to wcc/wpp causes them to freeze with 100% cpu use.

This is the kind of option that people will try their luck with, and build systems might attempt to probe it; should be worthwhile to make it more well behaved.

It looks like the option parser only increment for known values, so for c11 the global char pointer will likely be stuck at '1'.

while( !CmdScanSwEnd() ) {
if( CmdRecogChar( 'c' ) ) {
if( CmdRecogChar( '8' ) && CmdRecogChar( '9' ) ) {
cstd = STD_C89;
} else if( CmdRecogChar( '9' ) && CmdRecogChar( '9' ) ) {
cstd = STD_C99;
}
}
}

while( !CmdScanSwEnd() ) {
if( CmdRecogChar( 'c' )
&& CmdRecogChar( '+' )
&& CmdRecogChar( '+' ) ) {
if( CmdRecogChar( '9' )
&& CmdRecogChar( '8' ) ) {
cxxstd = STD_CXX98;
fail = false;
} else if( CmdRecogChar( '0' )
&& CmdRecogChar( 'x' ) ) {
cxxstd = STD_CXX0X;
fail = false;
}
}
}

@jmalak jmalak added bug C C compiler labels Jan 10, 2025
@jmalak
Copy link
Member

jmalak commented Jan 10, 2025

Thanks for your bug repport.
I think there should be a message about unsupported value and setup to latest supported value and skip unsupported value.

@negge
Copy link

negge commented Jan 17, 2025

I just ran into this infinite loop issue by passing -zastd=C99

jmalak added a commit that referenced this issue Jan 17, 2025
handle correctly invalid -zastd=.. option argument
@jmalak
Copy link
Member

jmalak commented Jan 17, 2025

It is fixed now and C compiler reports incorrect value and correctly process rest of option value.

@jmalak jmalak closed this as completed Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C C compiler
Projects
None yet
Development

No branches or pull requests

3 participants