public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "niemayer at isg dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/35593] New: spurious warning "array subscript is below array bounds" with void* function argument plus -O2
Date: Fri, 14 Mar 2008 20:11:00 -0000 [thread overview]
Message-ID: <bug-35593-1937@http.gcc.gnu.org/bugzilla/> (raw)
When compiling the following tiny example .cxx source with "-Wall -O2", I get
spurious warnings:
------------- cut example test.cxx here --------------
extern void function(void * x);
struct A {
long x;
char d[0];
};
void test(A * a) {
function((char *)a - 4); // gcc emits warning, here - why?
}
// ------------
struct B {
char d[0];
};
void test(B * b) {
char * c = (char *)b;
void * v = c-1;
function(v); // gcc emits warning, here - why?
}
------------- cut here --------------
The output of
> gcc -Wall -c test.cxx -O2
is:
/tmp/test.cxx: In function ‘void test(B*)’:
/tmp/test.cxx:22: warning: array subscript is below array bounds
/tmp/test.cxx: In function ‘void test(A*)’:
/tmp/test.cxx:10: warning: array subscript is below array bounds
I have not found a sane way in my non-example, real-world code to avoid those
warnings.
--
Summary: spurious warning "array subscript is below array bounds"
with void* function argument plus -O2
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: niemayer at isg dot de
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35593
next reply other threads:[~2008-03-14 20:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-14 20:11 niemayer at isg dot de [this message]
2008-03-14 22:45 ` [Bug middle-end/35593] [4.3 Regression] " rguenth at gcc dot gnu dot org
2008-03-14 22:45 ` rguenth at gcc dot gnu dot org
2008-03-15 14:29 ` rguenth at gcc dot gnu dot org
2008-03-15 16:10 ` rguenth at gcc dot gnu dot org
2008-03-15 19:15 ` rguenth at gcc dot gnu dot org
2008-03-18 17:25 ` rguenth at gcc dot gnu dot org
2008-03-18 17:28 ` rguenth at gcc dot gnu dot org
2009-06-03 5:07 ` at dot wufei at gmail dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-35593-1937@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).