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

if ( somepointer) fails #187

Open
GoogleCodeExporter opened this issue Oct 14, 2015 · 0 comments
Open

if ( somepointer) fails #187

GoogleCodeExporter opened this issue Oct 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
Simple input to generate the problem using interactive mode:
$ ./picoc -i
picoc> int *i = NULL;
picoc> if (i) printf("i\n"); else printf("NULL\n");

What is the expected output? What do you see instead?
Expected: NULL
Instead: :2:6 integer value expected instead of int*


What version of the product are you using? On what operating system?
OS X, picoc 603


Please provide any additional information below.
The problem is with expression.c:ExpressionParseInt(). The method uses "if 
(!IS_NUMERIC_COERCIBLE(Val))" to decide if the value can be used. It's legal to 
use a pointer in this form of if statement as a shorthand form of "if (pointer 
!= NULL)" but this macro doesn't allow for that. Changing the check to the 
following works but may introduce other problems? if 
(!IS_NUMERIC_COERCIBLE(Val) && !(Val->Typ->Base == TypePointer))

Original issue reported on code.google.com by [email protected] on 4 Nov 2013 at 6:22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant