fb39ca4 / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

if ( somepointer) fails #187

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 m...@heilpern.com on 4 Nov 2013 at 6:22