[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

Jim Michaels jmichae3 at yahoo dot com changed:

   What|Removed |Added

  Attachment #26948|0   |1
is obsolete||

--- Comment #2 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
06:07:22 UTC ---
Created attachment 26949
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26949
the code which causes the warning, maxint64-bug.cpp


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #3 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
06:13:33 UTC ---
you are not paying attention to the issue.  the issue is that this constant is
causing a compiler warning when it should not, and the compiler is treating a
valid signed constant as an unsigned integer. 

I recompiled with added -fno-strict-aliasing -fwrapv arguments and I got this
message.

it should NOT be unsigned!

maxint64-bug.cpp:4:19: warning: integer constant is so large that it is
unsigned [enabled by default]
maxint64-bug.cpp:4:5: warning: this decimal constant is unsigned only in ISO
C90 [enabled by default]


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org 2012-03-22 
06:15:48 UTC ---
(In reply to comment #3)
 you are not paying attention to the issue.  the issue is that this constant is
 causing a compiler warning when it should not, and the compiler is treating a
 valid signed constant as an unsigned integer. 

No please re-read my comments.  There are two tokens there and the second token
the integer constant is too large to fit into a signed long long.  This is
where the warning comes from.  The negative sign is a separate token in C90/C99
from the integer constant.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #5 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
06:29:51 UTC ---
read my comments in the code.
-(2^(32-1)) is a valid constant for 32-bit signed integers.  I don't get a
warning for that.
-(2^(16-1)) is a valid constant for 16-bit signed integers.  I don't get a
warning for that.
-(2^(8-1)) is a valid constant for 8-bit signed integers.  I don't get a
warning for that.

but -(2^(64-1)) is a valid constant for 64-bit signed integers,  and I get a
warning for that.

what for?  what possible reason is there for that?  these are valid integers!
  everybody knows what the range of int64_t and long long are.  but someone
goofed on this one.

looks to me like a bug.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #6 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
06:38:31 UTC ---
Created attachment 26950
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26950
maxint64-bug2.cpp - shows difference between different kinds of integers


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #7 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
06:40:36 UTC ---
I didn't intend forthe bug system to glob ontothe filename as a bug number.
sorry.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #8 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
07:06:31 UTC ---
I think if I understand you correctly, you are saying that the integer and the 


earlier code I tried did NOT use the L suffix.  I didn't get an warning then. 
which is as it should be.

but when I specified L or LL (which is the only thing you CAN do for really
long numbers like 64-bit integers, either of those suffixes with what should be
a valid signed integer value gives a warning as you say.

maxint64-bug2.cpp:6:5: warning: this decimal constant is unsigned only in ISO
C90 [enabled by default]
maxint64-bug2.cpp:7:19: warning: integer constant is so large that it is
unsigned [enabled by default]
maxint64-bug2.cpp:7:5: warning: this decimal constant is unsigned only in ISO
C90 [enabled by default]

the last 2 warnings are for the 64-bit integer using LL and the first one is
for the 32-bit one using L.

granted,it's not very often a person should want to use values like these, but
when someone wants to use them, but when they want to use them, they should be
available.

did someone mess up on the specification?


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #9 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
07:24:44 UTC ---
I will refer you to this since you don't believe me.
http://msdn.microsoft.com/en-us/library/2ayc1sk0.aspx


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #10 from Andrew Pinski pinskia at gcc dot gnu.org 2012-03-22 
18:47:04 UTC ---
(In reply to comment #9)
 I will refer you to this since you don't believe me.
 http://msdn.microsoft.com/en-us/library/2ayc1sk0.aspx

I understand that but you are understanding what I wrote.  There are two token
parsed separately.  - and 9223372036854775808LL are considered two different
tokens.  They are parsed separately which means the negative sign is not part
of the number.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #11 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
20:10:33 UTC ---
OK... then why do these warnings only show up on constants which have an or LL
suffix?
  I will show you a replacement test file shortly afterwards which has a 32-bit
number that does not give this warning, and a 32-bit number which does which
has the L suffix.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

Jim Michaels jmichae3 at yahoo dot com changed:

   What|Removed |Added

  Attachment #26949|0   |1
is obsolete||
  Attachment #26950|0   |1
is obsolete||

--- Comment #12 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
20:42:39 UTC ---
Created attachment 26959
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26959
maxint-bug.cpp, additional ints showing that 64-bit only causes problem

you are looking at the model of the compiler.  I am looking at the behavior
patterns of the compiler.  I am learning more and more as I put in more test
cases, like now.

it seems that whether an LL or not is added to a 64-bit number ONLY it causes a
warning.

your explanation of them being separate tokens I think has no bearing on what
turns this into a long long data type.  I think that once it is in this data
type, it is being mishandled.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #13 from Andrew Pinski pinskia at gcc dot gnu.org 2012-03-22 
20:54:17 UTC ---
First off take:
9223372036854775808LL

It is too large to fit into a signed long long so it is assumed as unsigned. 
That is what the warning is about.

What you have is:
- 9223372036854775808LL


So the parser comes along and see - and then 9223372036854775808LL as separate
tokens.  It is not warning that the value -9223372036854775808 is too large
but rather just 9223372036854775808LL is too large.

So basically this comes down to there are two separate tokens.

Please reread my comments, they have been saying the same thing a couple of
different ways.  Basically the negative sign is not part of the number token. 
This is on purpose to make tokenizer simpler and not need extra info from the
context around it.

like:

a -9223372036854775808LL.

THis is tokenized as three tokens, not two.  It would be hard to do some
parsing if it was tokenized as two, the tokenizer would need feedback from the
parser itself.  That would make the C/C++ really more complex then they are
currently.


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #14 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
21:45:33 UTC ---
OK, given your argument, let's look at -32768 for a short.
it's just too big because 32768 is larger than the size of an int, so it's
considered unsigned, right?  wrong.  no warning message.

which is what I have been trying to say.  your argument doesn't hold water.
this value is within the proper size for an int.  it's the minimum number of an
int.


-32768 is the one value that is valid which doesn't fit most people's use of an
int, which is only the range -32767..32767.  that is NOT the full range of a
short.

I am not sure why you are rooting for the compiler's way of doing things, it's
broken.  I understand what you are saying, I also understand that assuming the
value is unsigned because it's on the edge is wrong.  how about an if
statement, like
if (-1==sign  9223372036854775808==mantissa) {
datum=mantissa*sign;
} else if (1==sign  9223372036854775808==mantissa) {
datum=mantissa;
} else if (-1==sign  mantissa  9223372036854775808) {
printf(error:\n);
} else if (1==sign  mantissa  9223372036854775808) {
printf(error:\n);
}

why not just use an unsigned long long to hold the mantissa and keep the sign
as a bool or store it as another number as +1 or -1, and do some sort of range
check to make sure the number input is valid?  there are multiple ways


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #15 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
21:54:16 UTC ---
oops, made amistake there.

if (-1==sign  9223372036854775808==mantissa) {
datum=mantissa*sign;
} else if (1==sign  9223372036854775808==mantissa) {
datum=mantissa;
} else if (-1==sign  mantissa  9223372036854775808) {
printf(error:\n);
} else if (1==sign  mantissa  9223372036854775808) {
printf(error:\n);
} else {
datum=sign*mantissa;
}


[Bug c/52661] negative maxint for long long gives warning

2012-03-22 Thread jmichae3 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #16 from Jim Michaels jmichae3 at yahoo dot com 2012-03-22 
22:23:18 UTC ---
I realize it's going to be more complicated than this.


[Bug c/52661] negative maxint for long long gives warning

2012-03-21 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #1 from Andrew Pinski pinskia at gcc dot gnu.org 2012-03-22 
05:58:48 UTC ---
-9223372036854775808LL is two tokens - and 9223372036854775808LL which means
the warning is correct.  If you want -9223372036854775808LL without a warning
use:
-9223372036854775801LL -1 or better yet just use LONG_LONG_MIN .