public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined
       [not found] <bug-31290-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-19 19:28 ` pinskia at gcc dot gnu.org
  2022-08-30  7:08 ` pkk at spth dot de
  2022-08-30 15:19 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-19 19:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31290

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED
   Target Milestone|---                         |4.7.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
gcc.c-torture/execute/920612-1.c was fixed with r0-109082.
gcc.c-torture/execute/920711-1.c was fixed with r0-109083.

So closing as fixed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined
       [not found] <bug-31290-4@http.gcc.gnu.org/bugzilla/>
  2021-07-19 19:28 ` [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined pinskia at gcc dot gnu.org
@ 2022-08-30  7:08 ` pkk at spth dot de
  2022-08-30 15:19 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pkk at spth dot de @ 2022-08-30  7:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31290

Philipp <pkk at spth dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pkk at spth dot de

--- Comment #4 from Philipp <pkk at spth dot de> ---
I disagree about this bug for gcc.c-torture/execute/920711-1.c. I think there
was no bug here, and the "fix" actually introduced a problem, and should be
reverted:

I do not see signed integer overflow here:

f (0x80000000L)

Unless explicitly noted otherwise, all section numbers in the following refer
to the C2X standard draft N3047.

The 0x80000000L might be outside the range of long (i.e. on systems where long
has 32 bits). In that case, it will have type long long, as per the table in
section 6.4.4.1. Since the argument to f is of type long, it will get converted
to type long. That is not undefined, but implementation-defined according to
section 6.3.1.3.
By section 4.5 of the GCC manual
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html#Integers-implementation
the result of the conversion is -1.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined
       [not found] <bug-31290-4@http.gcc.gnu.org/bugzilla/>
  2021-07-19 19:28 ` [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined pinskia at gcc dot gnu.org
  2022-08-30  7:08 ` pkk at spth dot de
@ 2022-08-30 15:19 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-30 15:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31290

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Philipp from comment #4)
> I disagree about this bug for gcc.c-torture/execute/920711-1.c. I think
> there was no bug here, and the "fix" actually introduced a problem, and
> should be reverted:

No there is a bug.
int f(long a){return (--a > 0);}
int main(){if(f(0x80000000L)==0)abort();exit(0);}


0x80000000L is still 0x80000000 bitwise. so we get 0x80000000L - 1 which is
undefined if long is 32bits. If long is 64bits then 0x80000000L is still that
(and no implementation defined casting) and not undefined there.

> By section 4.5 of the GCC manual https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html#Integers-implementation the result of the conversion is -1.

No it is INT_MIN (for 32bit long):
For conversion to a type of width N, the value is reduced modulo 2^N to be
within range of the type; no signal is raised.

That means 0x80000000ULL will be 0x80000000L (if long is 32bits and long long
is 64bit).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined
  2007-03-21  0:43 [Bug testsuite/31290] New: gcc.c-torture/execute/920612-1.c depends on " pinskia at gcc dot gnu dot org
@ 2007-03-21 14:56 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-21 14:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-03-21 14:56 -------
gcc.c-torture/execute/920711-1.c has exactly the same issue.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|gcc.c-                      |gcc.c-
                   |torture/execute/920612-1.c  |torture/execute/920612-1.c
                   |depends on overflow being   |and gcc.c-
                   |defined                     |torture/execute/920711-1.c
                   |                            |depend on signed overflow
                   |                            |being defined


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-30 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-31290-4@http.gcc.gnu.org/bugzilla/>
2021-07-19 19:28 ` [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined pinskia at gcc dot gnu.org
2022-08-30  7:08 ` pkk at spth dot de
2022-08-30 15:19 ` pinskia at gcc dot gnu.org
2007-03-21  0:43 [Bug testsuite/31290] New: gcc.c-torture/execute/920612-1.c depends on " pinskia at gcc dot gnu dot org
2007-03-21 14:56 ` [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed " pinskia at gcc dot gnu dot org

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).