public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: preprocessor/8139: Bad new INT64_C macro
@ 2002-10-07 2:06 Philippe RIBET
0 siblings, 0 replies; 7+ messages in thread
From: Philippe RIBET @ 2002-10-07 2:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/8139; it has been noted by GNATS.
From: "Philippe RIBET" <philippe_ribet@hotmail.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc: philippe_ribet@hotmail.com
Subject: Re: preprocessor/8139: Bad new INT64_C macro
Date: Mon, 07 Oct 2002 08:59:44 +0000
>What is the new definition? What is this macro?
Old macro was:
# if __WORDSIZE == 64
# define INT64_C(c) c ## L
# else
# define INT64_C(c) c ## LL
# endif
New macro is:
#define INT64_C(val) (INT_LEAST64_MAX-INT_LEAST64_MAX+(val))
(in file include/stdint.h)
This macro is part of ANSI C99 standard. It allows to specify integer
constant size.
>I suspect the warnings are correct, but new, and that the definition
of the macro is unchanged.
No, definition changed.
No, warnings are not correct as INT64_C(-3000000000) is valid code because
-3000000000 is valid 64bits integer.
>You should probably add a U to the relevant numbers.
??? 'U' with negative numbers ???
>Anyway, not a GCC bug.
Is IS a GCC bug if you consider ANSI C99 standard.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8139
--
Philippe Ribet
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: preprocessor/8139: Bad new INT64_C macro
@ 2002-10-07 5:06 Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2002-10-07 5:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/8139; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: Neil Booth <neil@daikokuya.co.uk>
Cc: Philippe RIBET <philippe_ribet@hotmail.com>, gcc-gnats@gcc.gnu.org,
gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Subject: Re: preprocessor/8139: Bad new INT64_C macro
Date: Mon, 7 Oct 2002 04:57:15 -0700
On Mon, Oct 07, 2002 at 11:17:48AM +0100, Neil Booth wrote:
> But what is defining this macro? GCC, or your system?
Gcc does not provide <stdint.h>; glibc does.
> I don't think it really matters, though.
It does, because...
> Remember that with the new macro the token does not have L or LL
> appended, and therefore has type int (before promotions) in an
> arithmetic expression. This is what is causing the warning -
> the integer is too big.
... the whole point of this excercise is to get proper typing
of these constants. If "int" is 64-bit, for instance, then you
most certainly do not want L or LL appended.
It's a glibc bug.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: preprocessor/8139: Bad new INT64_C macro
@ 2002-10-07 3:26 Neil Booth
0 siblings, 0 replies; 7+ messages in thread
From: Neil Booth @ 2002-10-07 3:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/8139; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: Philippe RIBET <philippe_ribet@hotmail.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org
Subject: Re: preprocessor/8139: Bad new INT64_C macro
Date: Mon, 7 Oct 2002 11:17:48 +0100
Philippe RIBET wrote:-
> >What is the new definition? What is this macro?
>
> Old macro was:
>
> # if __WORDSIZE == 64
> # define INT64_C(c) c ## L
> # else
> # define INT64_C(c) c ## LL
> # endif
>
> New macro is:
> #define INT64_C(val) (INT_LEAST64_MAX-INT_LEAST64_MAX+(val))
But what is defining this macro? GCC, or your system? I don't
think it really matters, though.
Remember that with the new macro the token does not have L or LL
appended, and therefore has type int (before promotions) in an
arithmetic expression. This is what is causing the warning -
the integer is too big. You should probably add L or LL as
appropriate to your constants.
Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: preprocessor/8139: Bad new INT64_C macro
@ 2002-10-07 3:16 Neil Booth
0 siblings, 0 replies; 7+ messages in thread
From: Neil Booth @ 2002-10-07 3:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/8139; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: Philippe RIBET <philippe_ribet@hotmail.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org
Subject: Re: preprocessor/8139: Bad new INT64_C macro
Date: Mon, 7 Oct 2002 11:11:06 +0100
Philippe RIBET wrote:-
> >I suspect the warnings are correct, but new, and that the definition
> of the macro is unchanged.
> No, definition changed.
> No, warnings are not correct as INT64_C(-3000000000) is valid code because
> -3000000000 is valid 64bits integer.
No, that's your misunderstanding. The integer is 300000000; the -
is an operator, and it is not 64 bit. It has type int.
> >You should probably add a U to the relevant numbers.
> ??? 'U' with negative numbers ???
>
> >Anyway, not a GCC bug.
> Is IS a GCC bug if you consider ANSI C99 standard.
I don't think so. You can fix your code like I suggested.
Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: preprocessor/8139: Bad new INT64_C macro
@ 2002-10-05 2:28 neil
0 siblings, 0 replies; 7+ messages in thread
From: neil @ 2002-10-05 2:28 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, philippe_ribet
Synopsis: Bad new INT64_C macro
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Sat Oct 5 02:28:04 2002
State-Changed-Why:
You should probably add a U to the relevant numbers. Anyway, not a GCC bug.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8139
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: preprocessor/8139: Bad new INT64_C macro
@ 2002-10-04 15:16 Neil Booth
0 siblings, 0 replies; 7+ messages in thread
From: Neil Booth @ 2002-10-04 15:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/8139; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: philippe_ribet@hotmail.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/8139: Bad new INT64_C macro
Date: Fri, 4 Oct 2002 23:05:58 +0100
philippe_ribet@hotmail.com wrote:-
> Old INT64_C macro definition was value ## LL.
>
> New definition is probably better but then the compiler has to be modified accordingly.
What is the new definition? What is this macro?
> Note that all values are valid 64 bit numbers.
> The bug occured in the range -2^32+1 .. -2^31.
> >How-To-Repeat:
> #include <inttypes.h>
>
> main(){
> int64_t v;
>
> v = INT64_C(-2147483648);
> v = INT64_C(-3000000000);
> v = INT64_C(-4000000000);
> v = INT64_C(-5000000000);
> }
>
> $ gcc t.c
> t.c: In function `main':
> t.c:6: warning: decimal constant is so large that it is unsigned
> t.c:7: warning: decimal constant is so large that it is unsigned
> t.c:8: warning: decimal constant is so large that it is unsigned
I don't think this macro is defined by GCC. Is it system specific?
I suspect the warnings are correct, but new, and that the definition
of the macro is unchanged.
Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* preprocessor/8139: Bad new INT64_C macro
@ 2002-10-04 2:26 philippe_ribet
0 siblings, 0 replies; 7+ messages in thread
From: philippe_ribet @ 2002-10-04 2:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 8139
>Category: preprocessor
>Synopsis: Bad new INT64_C macro
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 04 02:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: philippe_ribet@hotmail.com
>Release: 3.2
>Organization:
>Environment:
>Description:
Old INT64_C macro definition was value ## LL.
New definition is probably better but then the compiler has to be modified accordingly.
Note that all values are valid 64 bit numbers.
The bug occured in the range -2^32+1 .. -2^31.
>How-To-Repeat:
#include <inttypes.h>
main(){
int64_t v;
v = INT64_C(-2147483648);
v = INT64_C(-3000000000);
v = INT64_C(-4000000000);
v = INT64_C(-5000000000);
}
$ gcc t.c
t.c: In function `main':
t.c:6: warning: decimal constant is so large that it is unsigned
t.c:7: warning: decimal constant is so large that it is unsigned
t.c:8: warning: decimal constant is so large that it is unsigned
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-10-07 12:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-07 2:06 preprocessor/8139: Bad new INT64_C macro Philippe RIBET
-- strict thread matches above, loose matches on Subject: below --
2002-10-07 5:06 Richard Henderson
2002-10-07 3:26 Neil Booth
2002-10-07 3:16 Neil Booth
2002-10-05 2:28 neil
2002-10-04 15:16 Neil Booth
2002-10-04 2:26 philippe_ribet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).