[Bug c/30475] assert(int+100 > int) optimized away

felix-gcc at fefe dot de gcc-bugzilla@gcc.gnu.org
Sun Jan 21 17:47:00 GMT 2007



------- Comment #36 from felix-gcc at fefe dot de  2007-01-21 17:47 -------
I think the actual root issue here is that the gcc argumentation is
fundamentally wrong.  I am complaining that gcc removes my checks, not that
signed integer overflow is undefined.

Also, note that it is everything BUT undefined.  Adding 5 to INT_MAX will
create a negative number.  It behaves EXACTLY as expected by basically
everyone.  And if gcc decided that it is undefined and it creates INT_MAX
again, then I would be happy, too.  No problem with that whatsoever.

All I want is gcc to be consistent.  gcc DOES create a negative number.  And
then it removes an if statement asking whether the number is negative.  That
can not be explained away with signed int overflow being undefined.  Let's
write it in separate statements, so even the biggest idiot in the world can
understand the issue.

  int a,b,c;
  a=INT_MAX;     /* statement ONE */
  b=a+2;         /* statement TWO */
  c=(b>a);       /* statement THREE */

My issue with gcc is that it removes statement THREE.  Your argument about
undefinedness is about statement TWO.  Following your argumentation, gcc is
allowed to return 23 in statement TWO.  But it still not allowed to generate no
code for statement THREE.

In my opinion, people who don't understand this most basic of logic should not
be let NEAR the code of a compiler, let alone a compiler millions of people are
depending on.

Now, to summarize.  We destroyed your complete argument, including wild
assertions you happened to make during its course.  We gave evidence that the
current behavior is bad for a lot of people.  What more do you need to see
reason?  Do you want a bribe?  Some more crack?  Hookers, maybe?  I don't see
what else could be discussed about the matter.  I will refrain from wasting
time on trying to find new way to explain the obvious to you.  From now on,
I'll just auto-reopen the bug and say "see previous arguments".


-- 

felix-gcc at fefe dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|WONTFIX                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475



More information about the Gcc-bugs mailing list