bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: examples/loadables/getconf.c


From: Chet Ramey
Subject: Re: examples/loadables/getconf.c
Date: Fri, 05 Oct 2012 11:39:20 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1

On 10/5/12 11:27 AM, Greg Wooledge wrote:
> On Fri, Oct 05, 2012 at 05:20:23PM +0200, Andreas Schwab wrote:
>> Greg Wooledge <address@hidden> writes:
>>
>>> Line 1209 says:
>>> #  if (ULLONG_MAX != LLONG_MAX)
>>>
>>> LLONG_MAX expands to:
>>> ((long long int) (~ (long long int) 0 - ((long long int) ((! ((long long 
>>> int) 0 < (long long int) -1)) ? ~ (long long int) 0 << (sizeof (long long 
>>> int) * 8 - 1) : (long long int) 0))))
>>
>> That's not a valid expansion for this macro, it cannot contain casts or
>> the sizeof operator.
> 
> Then there's a serious problem somewhere, because that's what gcc -E is
> giving me.  Copying the top part of getconf.c and then jumping straight
> to the heart of the matter:

> # 1 "getconf.h" 1
> # 31 "foo.c" 2
> 
> 
> extern int errno;
> 
> 
> ((long long int) (~ (long long int) 0 - ((long long int) ((! ((long long int) 
> 0 < (long long int) -1)) ? ~ (long long int) 0 << (sizeof (long long int) * 8 
> - 1) : (long long int) 0))))

That looks like it comes from include/typemax.h.  I derived the macros
there from an earlier version of the god-awful mess that appears in
gnulib's strtol.c, ammong other places.  It hasn't changed in a long time.

Why would you say there's a restriction against using casts or sizeof in
a macro like this?  Even the newer versions of that code in gnulib use
them.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]