public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53084] New: GCC cannot handle array initialization of string constant with point arithmetic properly
@ 2012-04-23 10:07 ray_linn at hotmail dot com
  2012-04-23 10:23 ` [Bug c/53084] [4.7/4.8 Regression] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ray_linn at hotmail dot com @ 2012-04-23 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53084
           Summary: GCC cannot handle array initialization of string
                    constant with point arithmetic properly
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ray_linn@hotmail.com


Consider the following code:

#include <stdio.h>
int main() {
static const char *const aa[] = {"foo"+1};
printf("aa[0] = %s\n",aa[0]);
return 0;
}

 works fine on GCC 4.5.2 and 4.6.1
C:\work>gcc --version
gcc (tdm-1) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\work>gcc a.c -oa.exe

C:\work>a
aa[0] = oo


C:\work>gcc --version
gcc (tdm-1) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\work>gcc a.c -oa.exe

C:\work>a
aa[0] = oo

On GCC 4.7.0, it fails with segmentation fault.

C:\work>gcc --version
gcc (GCC) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\work>gcc a.c -oa.exe

C:\work>a

(error dialog)


Please go there to find the original bug threads: 
http://bugs.ruby-lang.org/issues/6333


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

end of thread, other threads:[~2012-04-24  9:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-23 10:07 [Bug c/53084] New: GCC cannot handle array initialization of string constant with point arithmetic properly ray_linn at hotmail dot com
2012-04-23 10:23 ` [Bug c/53084] [4.7/4.8 Regression] " rguenth at gcc dot gnu.org
2012-04-23 10:25 ` ktietz at gcc dot gnu.org
2012-04-23 16:47 ` jakub at gcc dot gnu.org
2012-04-23 17:19 ` ktietz at gcc dot gnu.org
2012-04-23 17:46 ` jakub at gcc dot gnu.org
2012-04-23 19:51 ` [Bug middle-end/53084] " jakub at gcc dot gnu.org
2012-04-23 20:14 ` ktietz at gcc dot gnu.org
2012-04-24  6:08 ` jakub at gcc dot gnu.org
2012-04-24  6:11 ` jakub at gcc dot gnu.org
2012-04-24  6:15 ` jakub at gcc dot gnu.org
2012-04-24  9:40 ` jakub 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).