cpphs bug

Malcolm Wallace malcolm.wallace at me.com
Fri Feb 21 18:37:04 UTC 2014


On 21 Feb 2014, at 16:04, Roman Cheplyaka wrote:

> This appears to be a cpphs bug. For the following code
> 
>    #define x (1 == 1)
>    #if x
>    YES
>    #else
>    NO
>    #endif
> 
> cpphs 1.18.1 prints NO, while the expected output (and the output GNU
> cpp produces) is YES.


I acknowledge that this is a bug in cpphs.  It is actually a bit worse than this - the following code also outputs NO with cpphs, when it should clearly be YES:

    #define x   0 == 0
    #if x
    YES
    #else
    NO
    #endif

It is all to do with the recursive expansion of symbols during parsing, where currently we are interpreting the first symbol in the expansion as the intended boolean value, rather than re-parsing the whole expanded expression.  Fixing it will be a little bit more involved than just adding another clause to the parser, but I'm on it.

Regards,
    Malcolm


More information about the ghc-devs mailing list