This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53084] New: GCC cannot handle array initialization of string constant with point arithmetic properly
- From: "ray_linn at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Apr 2012 10:07:01 +0000
- Subject: [Bug c/53084] New: GCC cannot handle array initialization of string constant with point arithmetic properly
- Auto-submitted: auto-generated
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