Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 13 Jan 2013 13:46:28 -0600
From: Rob Landley <>
Subject: Re: NULL

On 01/13/2013 11:47:32 AM, Szabolcs Nagy wrote:
> > So I think you're saying is that the behavior I'm depending on  
> changed?
> well,
> (int)(void*)0 is not an "integer constant expression" and it
> is not a "null pointer constant",

C99 An integer constant expression with the value 0, or such  
an expression cast to type void *, is called a null pointer constant.

7.17 #3: The macros are NULL which expands to an implementation-defined  
null pointer constant;

So it uses "constant" in the name but either it's not a constant or  
typecasting it twice makes it stop being a constant.

> it is not an "arithmetic
> constant expression" nor an "address constant", but an
> implementation is allowed to accept it as a "constant expression"
> anyway
> (as far as i can see it is not required to though)

Actually it turned out the problem was I accidentally checked in some  
debug code, which set -O0 (which apparently disables --gc-sections even  
when explicitly specified).

So it's still working fine. Whether or not it should depends on whether  
or not "constant" means it's a constant.

> !(void*)0 and (void*)0 || (void*)0 are similar
> in initializers they may be accepted, but the standard
> does not require them to be

At one point, I had to dig through all this stuff:

Alas, that was about 5 years ago and I no longer remember the details.

> gcc used to be less strict integer constant expressions,
> but recently it follows the standard more closely
> > Sigh. Yup. When I build toybox with just "true", gcc 4.2.1 (last gpl
> > release) drops out parse_optflag() but the ubuntu host toolchain no
> > longer does.
> i think gcc should be able to do the optimization

It can, it was -O0. Pilot error. :)


Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.