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
* [Bug c/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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 ` rguenth at gcc dot gnu.org
2012-04-23 10:25 ` ktietz at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-23 10:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |wrong-code
Last reconfirmed| |2012-04-23
Ever Confirmed|0 |1
Summary|GCC cannot handle array |[4.7/4.8 Regression] GCC
|initialization of string |cannot handle array
|constant with point |initialization of string
|arithmetic properly |constant with point
| |arithmetic properly
Target Milestone|--- |4.7.1
Severity|critical |normal
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-23 10:22:34 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-04-23 10:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
--- Comment #2 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-04-23 10:25:05 UTC ---
I can confirm it with trunk version for -O0, too.
Issue is that there seems to be a wrong-code generation bug for O0 and
read-only section data.
...
movq aa.2567(%rip), %rax
movq %rax, %rdx
leaq .LC0(%rip), %rcx
call printf
...
...
.data
.align 8
aa.2567:
.section .rdata,"dr"
.LC1:
.ascii "foo\0"
.quad .LC1+1
...
The aa.2567 label is emitted in data, but its definition in .rdata
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-23 16:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-23 16:47:32 UTC ---
Can't reproduce on x86_64-linux, please fill in Target.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (2 preceding siblings ...)
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
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-04-23 17:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
Kai Tietz <ktietz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|*-*-mingw* |x86_64-*-* i686-*-*
--- Comment #4 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-04-23 17:19:27 UTC ---
(In reply to comment #3)
> Can't reproduce on x86_64-linux, please fill in Target.
Hmm, I can. For x86_64-unknown-linux-gnu using -O0 as optimization option, I
see for this test
aa.2162:
.LC1:
.string "foo"
.quad .LC1+1
which is wrong, too.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (3 preceding siblings ...)
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
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-23 17:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-23 17:45:55 UTC ---
I don't see that on the trunk:
.section .rodata
.LC1:
.string "foo"
.align 8
.type aa.1706, @object
.size aa.1706, 8
aa.1706:
.quad .LC1+1
Ah, but looking at current 4.7, I can reproduce that. Will look at it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (4 preceding siblings ...)
2012-04-23 17:46 ` jakub at gcc dot gnu.org
@ 2012-04-23 19:51 ` jakub at gcc dot gnu.org
2012-04-23 20:14 ` ktietz at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-23 19:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org
|gnu.org |
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-23 19:50:40 UTC ---
Created attachment 27226
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27226
gcc47-pr53084.patch
Untested fix.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (5 preceding siblings ...)
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
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-04-23 20:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
--- Comment #7 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-04-23 20:14:05 UTC ---
This patch fixes issues for noticed for mingw targets on trunk and for 4.7.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (6 preceding siblings ...)
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
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-24 6:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-24 06:07:34 UTC ---
Author: jakub
Date: Tue Apr 24 06:07:30 2012
New Revision: 186742
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186742
Log:
PR middle-end/53084
* varasm.c (compute_reloc_for_constant): Handle ADDR_EXPR
of MEM_REF.
(output_addressed_constants): Likewise.
* gcc.c-torture/execute/pr53084.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr53084.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/varasm.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (7 preceding siblings ...)
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
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-24 6:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-24 06:11:00 UTC ---
Author: jakub
Date: Tue Apr 24 06:10:53 2012
New Revision: 186745
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186745
Log:
PR middle-end/53084
* varasm.c (compute_reloc_for_constant): Handle ADDR_EXPR
of MEM_REF.
(output_addressed_constants): Likewise.
* gcc.c-torture/execute/pr53084.c: New test.
Added:
branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/execute/pr53084.c
Modified:
branches/gcc-4_7-branch/gcc/ChangeLog
branches/gcc-4_7-branch/gcc/varasm.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (8 preceding siblings ...)
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
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-24 6:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-24 06:14:43 UTC ---
Author: jakub
Date: Tue Apr 24 06:14:37 2012
New Revision: 186746
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186746
Log:
PR middle-end/53084
* varasm.c (compute_reloc_for_constant): Handle ADDR_EXPR
of MEM_REF.
(output_addressed_constants): Likewise.
* gcc.c-torture/execute/pr53084.c: New test.
Added:
branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/execute/pr53084.c
Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
branches/gcc-4_6-branch/gcc/varasm.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/53084] [4.7/4.8 Regression] GCC cannot handle array initialization of string constant with point arithmetic properly
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
` (9 preceding siblings ...)
2012-04-24 6:15 ` jakub at gcc dot gnu.org
@ 2012-04-24 9:40 ` jakub at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-04-24 9:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53084
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-24 09:40:17 UTC ---
Should be fixed now.
^ 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).