public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48850] New: Bogus overflow in constant expression warning
@ 2011-05-03  8:59 rguenth at gcc dot gnu.org
  2011-05-03 10:46 ` [Bug c/48850] " joseph at codesourcery dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-03  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Bogus overflow in constant expression warning
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: diagnostic, rejects-valid
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org


typedef __SIZE_TYPE__ size_t;

extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "too large" } */
extern char b[((size_t)-1 >> 1)];
extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "too large"
} */
extern int d[((size_t)-1 >> 1) / sizeof(int)];

is rejected with -pendantic-errors:

t.c:3:13: error: size of array 'a' is too large
t.c:4:1: error: overflow in constant expression [-Woverflow]
t.c:5:12: error: size of array 'c' is too large
t.c:6:1: error: overflow in constant expression [-Woverflow]

the overflows reported are bogus.


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

* [Bug c/48850] Bogus overflow in constant expression warning
  2011-05-03  8:59 [Bug c/48850] New: Bogus overflow in constant expression warning rguenth at gcc dot gnu.org
@ 2011-05-03 10:46 ` joseph at codesourcery dot com
  2011-12-15 23:51 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2011-05-03 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-05-03 10:45:43 UTC ---
Remarks:

* This is clearly a bug; the diagnostics given are simply wrong.

* It's not a conformance bug, as C99 permits a limit on object size as 
small as 64KiB (in a hosted environment) (and the apparent limit here - 
see <http://gcc.gnu.org/ml/gcc-patches/2011-05/msg00096.html> - is 1EiB).

* If it's hard to support such large objects for some reason, a call to 
sorry () is the appropriate way to diagnose the lack of support instead of 
incorrect overflow diagnostics.  There would still be a bug, since GNU 
programs should avoid arbitrary limits (meaning anything smaller than that 
imposed by the target instruction set, C semantics, ABI etc.), but a less 
serious one (GCC is full of inappropriate arbitrary limits, such as 2GB 
for a string constant, but the only ones people seem to encounter in 
practice are those from stack overflow).


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

* [Bug c/48850] Bogus overflow in constant expression warning
  2011-05-03  8:59 [Bug c/48850] New: Bogus overflow in constant expression warning rguenth at gcc dot gnu.org
  2011-05-03 10:46 ` [Bug c/48850] " joseph at codesourcery dot com
@ 2011-12-15 23:51 ` pinskia at gcc dot gnu.org
  2014-09-25  9:00 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-15 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-15
     Ever Confirmed|0                           |1


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

* [Bug c/48850] Bogus overflow in constant expression warning
  2011-05-03  8:59 [Bug c/48850] New: Bogus overflow in constant expression warning rguenth at gcc dot gnu.org
  2011-05-03 10:46 ` [Bug c/48850] " joseph at codesourcery dot com
  2011-12-15 23:51 ` pinskia at gcc dot gnu.org
@ 2014-09-25  9:00 ` mpolacek at gcc dot gnu.org
  2015-06-16 12:42 ` [Bug c++/48850] " rguenth at gcc dot gnu.org
  2021-12-03  3:55 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-09-25  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |mpolacek at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Seems to be fixed now: the "overflow in constant expression" is gone.


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

* [Bug c++/48850] Bogus overflow in constant expression warning
  2011-05-03  8:59 [Bug c/48850] New: Bogus overflow in constant expression warning rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-09-25  9:00 ` mpolacek at gcc dot gnu.org
@ 2015-06-16 12:42 ` rguenth at gcc dot gnu.org
  2021-12-03  3:55 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-16 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |
             Status|RESOLVED                    |REOPENED
          Component|c                           |c++
         Resolution|FIXED                       |---
      Known to fail|                            |5.0

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Still present with the C++ frontend though.

> g++-5 -S t.c 
t.c:3:36: warning: integer overflow in expression [-Woverflow]
 extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "too large" } */
                                    ^
t.c:3:36: error: overflow in array dimension
t.c:3:36: error: size of array ‘a’ is too large
t.c:5:51: error: size of array ‘c’ is too large
 extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "too large"
>From gcc-bugs-return-489085-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 16 13:10:32 2015
Return-Path: <gcc-bugs-return-489085-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27065 invoked by alias); 16 Jun 2015 13:10:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27007 invoked by uid 48); 16 Jun 2015 13:10:27 -0000
From: "doko at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/66554] New: [4.9 Regression] ICE (in expand_fix, at optabs.c:5365) on aarch64-linux-gnu
Date: Tue, 16 Jun 2015 13:10:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: doko at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone
Message-ID: <bug-66554-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg01417.txt.bz2
Content-length: 979

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf554

            Bug ID: 66554
           Summary: [4.9 Regression] ICE (in expand_fix, at optabs.c:5365)
                    on aarch64-linux-gnu
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org
  Target Milestone: ---

works with 4.7, didn't check 4.8, fails with 4.9, works with 5. -O2 works
around it.

$ cat source.ii
float *a;
unsigned b;
void fn1() {
  for (int c; c; ++c) {
    b = c;
    a[c] = b;
    a[c] = ({ short(a[c]) << 8; });
  }
}

$ g++-4.9 -c -O3 source.ii
source.ii: In function 'void fn1()':
source.ii:7:27: internal compiler error: in expand_fix, at optabs.c:5365
     a[c] = ({ short(a[c]) << 8; });
                           ^
Please submit a full bug report,
with preprocessed source if appropriate.


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

* [Bug c++/48850] Bogus overflow in constant expression warning
  2011-05-03  8:59 [Bug c/48850] New: Bogus overflow in constant expression warning rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-06-16 12:42 ` [Bug c++/48850] " rguenth at gcc dot gnu.org
@ 2021-12-03  3:55 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03  3:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=87996
      Known to work|                            |11.1.0, 9.1.0
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |9.0

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC 9+ give:

<source>:3:33: error: size '9223372036854775808' of array 'a' exceeds maximum
object size '9223372036854775807'
    3 | extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "too large" } */
      |               ~~~~~~~~~~~~~~~~~~^~~
<source>:5:12: error: size '9223372036854775808' of array 'c' exceeds maximum
object size '9223372036854775807'
    5 | extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "too
large" } */
      |            ^



Fixed by r9-5932-g28a8cef1e240 (PR 87996).

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

end of thread, other threads:[~2021-12-03  3:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-03  8:59 [Bug c/48850] New: Bogus overflow in constant expression warning rguenth at gcc dot gnu.org
2011-05-03 10:46 ` [Bug c/48850] " joseph at codesourcery dot com
2011-12-15 23:51 ` pinskia at gcc dot gnu.org
2014-09-25  9:00 ` mpolacek at gcc dot gnu.org
2015-06-16 12:42 ` [Bug c++/48850] " rguenth at gcc dot gnu.org
2021-12-03  3:55 ` pinskia at gcc dot gnu.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).