* compiler warning about literal
@ 2014-11-17 16:22 Luchezar Belev
2014-11-17 16:45 ` Luchezar Belev
2014-11-17 16:46 ` Jonathan Wakely
0 siblings, 2 replies; 6+ messages in thread
From: Luchezar Belev @ 2014-11-17 16:22 UTC (permalink / raw)
To: gcc-help
hi,
when i try to compile this c code:
long long t = 2684354560;
gcc (version 4.8.2) says: " ...warning: this decimal constant is
unsigned only in ISO C90 [enabled by default]"
i added the option -std=C90 but i still get the same warning.
Is there a way one can get rid of this warning (other than adding the
"u" suffix to the literal, which i can't do for complicated reasons
that are beyond this question)
I wonder why does gcc give such warning at all given that in either
standard the literal decimal number "2684354560" is valid:
a) in ISO C90 it will be interpreted as unsigned long and
b) in ISO C99 it will be interpreted as signed long long
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: compiler warning about literal
2014-11-17 16:22 compiler warning about literal Luchezar Belev
@ 2014-11-17 16:45 ` Luchezar Belev
2014-11-17 16:50 ` Nicholas Mc Guire
2014-11-17 16:46 ` Jonathan Wakely
1 sibling, 1 reply; 6+ messages in thread
From: Luchezar Belev @ 2014-11-17 16:45 UTC (permalink / raw)
To: gcc-help
note the following strange gcc behavior:
"long long t = 268435456;" =>doesn't give warning
"long long t = 2684354560;" => gives warning!
"long long t = 26843545600;" => doesn't give warning!
it looks to me that there is something wrong here
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: compiler warning about literal
2014-11-17 16:22 compiler warning about literal Luchezar Belev
2014-11-17 16:45 ` Luchezar Belev
@ 2014-11-17 16:46 ` Jonathan Wakely
1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2014-11-17 16:46 UTC (permalink / raw)
To: Luchezar Belev; +Cc: gcc-help
On 17 November 2014 16:22, Luchezar Belev <lukcho@gmail.com> wrote:
> hi,
>
> when i try to compile this c code:
> long long t = 2684354560;
> gcc (version 4.8.2) says: " ...warning: this decimal constant is
> unsigned only in ISO C90 [enabled by default]"
>
> i added the option -std=C90 but i still get the same warning.
> Is there a way one can get rid of this warning (other than adding the
> "u" suffix to the literal, which i can't do for complicated reasons
> that are beyond this question)
The right thing to do is use an ll suffix.
long long t = 2684354560ll;
> I wonder why does gcc give such warning at all given that in either
> standard the literal decimal number "2684354560" is valid:
> a) in ISO C90 it will be interpreted as unsigned long and
> b) in ISO C99 it will be interpreted as signed long long
The fact it means different things in different cases is why you get a warning.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-17 17:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-17 16:22 compiler warning about literal Luchezar Belev
2014-11-17 16:45 ` Luchezar Belev
2014-11-17 16:50 ` Nicholas Mc Guire
[not found] ` <CAJtzQrzHnh_=_UZ=-y=HZEBVQYgWFzGVzvUTLG6U_HVtxObfhQ@mail.gmail.com>
[not found] ` <20141117170828.GA27808@opentech.at>
[not found] ` <20141117171418.GA30462@opentech.at>
2014-11-17 17:28 ` Luchezar Belev
2014-11-17 17:34 ` Luchezar Belev
2014-11-17 16:46 ` Jonathan Wakely
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).