Sign in to follow this  

Bug in compiler

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

[CODE]enum E
{
VALUE1 = 20somegarbage,
VALUE2 = 30moregarbage
}[/CODE]

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 [b]as_tokenizer.cpp[/b] in method:

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

which identifies "[b]20somegarbage[/b]" and "[b]30moregarbage[/b]" as [b]ttIntConstant[/b]. In this loop:

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

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.

Thanks in advance!

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this