[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] More fun with comparison between pointer and integer.
From: |
Rob Landley |
Subject: |
Re: [Tinycc-devel] More fun with comparison between pointer and integer... |
Date: |
Wed, 5 Sep 2007 02:33:58 -0500 |
User-agent: |
KMail/1.9.6 |
On Wednesday 05 September 2007 1:02:03 am Dave Dodge wrote:
> > I fixed the "ptr || ptr" bit not working (check hg), and I just made it
> > stop warning me about "comparison between pointer and int" for && and ||,
> > but now it's saying "initializer element not constant".
>
> Well looking at 6.6, I'm having a hard time figuring out how to fit
> the above into one of the described forms of "constant expression".
> It's the use of pointers at all that causes the problem; most of the
> ways of defining such expressions seem to be constrained to using only
> arithmetic types.
It's a pointer to a constant string. It's in a read-only section of memory.
More to the point, the or is testing whether or not it's nonzero, so the
actual _value_ of the pointer goes away and all we need to retain is that it
wasn't NULL.
> I suspect your expression is falling into the gray area of "An
> implementation may accept other forms of constant expressions."
*shrug* GCC handles this just fine, that's why I was doing it. The
alternative is ugly and brittle #ifdefs instead of letting the optimizer
eliminate dead code naturally.
Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.
- [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer...,
Rob Landley <=
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Simon 'corecode' Schubert, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/06
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/05
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Rob Landley, 2007/09/06
- Re: [Tinycc-devel] More fun with comparison between pointer and integer..., Dave Dodge, 2007/09/06