• 13
• 15
• 19
• 27
• 9

# Bug in compiler

This topic is 2135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I think I've found a bug in a compiler. For the reproduction of this behaviour, use asrun sample, but modify the script in the script.as so the enum E looks similar to this one:

enum E { VALUE1 = 20somegarbage, VALUE2 = 30moregarbage }

The application will compile and run without any error. But it should throw some "bad suffix on number" error information.
I think that the problem is in as_tokenizer.cpp in method:

bool asCTokenizer::IsConstant(const char *source, size_t sourceLength, size_t &tokenLength, eTokenType &tokenType) const

which identifies "20somegarbage" and "30moregarbage" as ttIntConstant. In this loop:

 size_t n; for( n = 0; n < sourceLength; n++ ) { if( source[n] < '0' || source[n] > '9' ) break; } 

it only goes to first unallowed char (in this case "s" for the VALUE1) and does nothing about the fact that 20somegarbage is not a proper constant identifier here.

For this test I'm using HEAD revision (currently 1301), but this error is present in earlier versions of the AngelScript library.

##### Share on other sites
Yes, you're correct. I'll have this fixed.

Thanks for the detailed analysis on the problem.

##### Share on other sites
Thank you . You're welcome .

##### Share on other sites
I've fixed this bug in revision 1303.