[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Fun little bug...
From: |
Rob Landley |
Subject: |
[Tinycc-devel] Fun little bug... |
Date: |
Tue, 4 Sep 2007 23:29:46 -0500 |
User-agent: |
KMail/1.9.6 |
So I'm trying to get some code I wrote (toybox) to build under tcc. Ran into
the bug "cannot use pointers here", on code that (once the macros are
resolved) expands to:
int enable = NULL || 0;
And NULL, of course, expands to ( ( void * ) 0 ).
What tcc is saying is that NULL || 0 is illegal. Which is not, in fact, the
case. It's not even a warning, it's a commonish thing to do in if()
statements. You can do || and && for sure, and there's defined behavior for
> and < too. (The c99 draft spec is almost unreadable, by the way.)
Would anyone like to comment on the if statement starting at line 4799? If
there are two operands and only one of them is a pointer, it puts the pointer
first. Now the only thing it allows through to this point is subtraction,
but the spec says that for subtraction the _first_ operand must be the
pointer, ala "blah = ptr - 5"; I've heard of code that does "blah = 5 - ptr"
but only in the obfuscated C code contest, but in any case swapping them
wouldn't make sense, would it?
Does this chunk of code make more sense to anybody else here?
Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.