public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37745] New: Segmentation Fault Exception with -O and signed array index
@ 2008-10-06 11:17 gcc at jme dot de
2008-10-06 11:59 ` [Bug c/37745] " joseph at codesourcery dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gcc at jme dot de @ 2008-10-06 11:17 UTC (permalink / raw)
To: gcc-bugs
The following code produces a segmentation fault when compiled with -O.
Environment is GCC V4.2.2 (also tested with 4.1.2) on AVR32 Linux target.
Cross compiled on Cygwin.
With GCC V3.4.4 on Cygwin Target it works correct.
Even when I insert a printf("."); between the if and the for the code works.
static const unsigned aArr[] = {31,28,31};
unsigned Bla(unsigned u8)
{
unsigned u32;
int i,m;
u32=0;
m=u8;
if (m!=0) m--;
//printf(".");
for (i=0; i<m; i++) u32+=aArr[i];
return u32;
}
int main()
{
Bla(1);
return 0;
}
--
Summary: Segmentation Fault Exception with -O and signed array
index
Product: gcc
Version: 4.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at jme dot de
GCC host triplet: Cygwin
GCC target triplet: AVR32 Linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37745
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/37745] Segmentation Fault Exception with -O and signed array index
2008-10-06 11:17 [Bug c/37745] New: Segmentation Fault Exception with -O and signed array index gcc at jme dot de
@ 2008-10-06 11:59 ` joseph at codesourcery dot com
2008-10-06 16:00 ` rguenth at gcc dot gnu dot org
2008-10-07 23:31 ` gcc at jme dot de
2 siblings, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2008-10-06 11:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from joseph at codesourcery dot com 2008-10-06 11:58 -------
Subject: Re: New: Segmentation Fault Exception with -O and
signed array index
On Mon, 6 Oct 2008, gcc at jme dot de wrote:
> The following code produces a segmentation fault when compiled with -O.
> Environment is GCC V4.2.2 (also tested with 4.1.2) on AVR32 Linux target.
FSF GCC does not currently support AVR32, so you need to report this bug
to whoever you got your modified compiler with that support from. The bug
reporting instructions at <http://gcc.gnu.org/bugs.html> say:
What we do not want
...
* Bugs in releases or snapshots of GCC not issued by the GNU
Project. Report them to whoever provided you with the release
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37745
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/37745] Segmentation Fault Exception with -O and signed array index
2008-10-06 11:17 [Bug c/37745] New: Segmentation Fault Exception with -O and signed array index gcc at jme dot de
2008-10-06 11:59 ` [Bug c/37745] " joseph at codesourcery dot com
@ 2008-10-06 16:00 ` rguenth at gcc dot gnu dot org
2008-10-07 23:31 ` gcc at jme dot de
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-06 16:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2008-10-06 15:59 -------
This will invoke
for (i=0; i<0; i++)
which invokes undefined behavior on signed integer overflow.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37745
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/37745] Segmentation Fault Exception with -O and signed array index
2008-10-06 11:17 [Bug c/37745] New: Segmentation Fault Exception with -O and signed array index gcc at jme dot de
2008-10-06 11:59 ` [Bug c/37745] " joseph at codesourcery dot com
2008-10-06 16:00 ` rguenth at gcc dot gnu dot org
@ 2008-10-07 23:31 ` gcc at jme dot de
2 siblings, 0 replies; 4+ messages in thread
From: gcc at jme dot de @ 2008-10-07 23:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from gcc at jme dot de 2008-10-07 23:29 -------
Hi Joseph,
because the the problem occurs only with the compiler switch -O.
And the problem occurs not if I place a "printf("xx")" between
the two statements "if" and "for". Therefore, I thought it was a
more target independend optimization problem.
But now I'd checked this behaviour with i386 Linux
(after installing g++ with "apt-get install g++")
-> "gcc-Version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)"
and it works correct there.
I'll post the bug report to the AVR32 Linux site.
Sorry about wasting your time. This was my 1st bug post.
Next time I'll compare the behaviour on my Linux PC before posting.
Thanx,
Joe.(In reply to comment #1)
> Subject: Re: New: Segmentation Fault Exception with -O and
> signed array index
>
> On Mon, 6 Oct 2008, gcc at jme dot de wrote:
>
> > The following code produces a segmentation fault when compiled with -O.
> > Environment is GCC V4.2.2 (also tested with 4.1.2) on AVR32 Linux target.
>
> FSF GCC does not currently support AVR32, so you need to report this bug
> to whoever you got your modified compiler with that support from. The bug
> reporting instructions at <http://gcc.gnu.org/bugs.html> say:
>
> What we do not want
>
> ...
>
> * Bugs in releases or snapshots of GCC not issued by the GNU
> Project. Report them to whoever provided you with the release
>
(In reply to comment #1)
> Subject: Re: New: Segmentation Fault Exception with -O and
> signed array index
>
> On Mon, 6 Oct 2008, gcc at jme dot de wrote:
>
> > The following code produces a segmentation fault when compiled with -O.
> > Environment is GCC V4.2.2 (also tested with 4.1.2) on AVR32 Linux target.
>
> FSF GCC does not currently support AVR32, so you need to report this bug
> to whoever you got your modified compiler with that support from. The bug
> reporting instructions at <http://gcc.gnu.org/bugs.html> say:
>
> What we do not want
>
> ...
>
> * Bugs in releases or snapshots of GCC not issued by the GNU
> Project. Report them to whoever provided you with the release
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37745
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-07 23:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-06 11:17 [Bug c/37745] New: Segmentation Fault Exception with -O and signed array index gcc at jme dot de
2008-10-06 11:59 ` [Bug c/37745] " joseph at codesourcery dot com
2008-10-06 16:00 ` rguenth at gcc dot gnu dot org
2008-10-07 23:31 ` gcc at jme dot de
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).