User account creation filtered due to spam.

Bug 18129 - [3.4 Regression] -fwritable-strings doesn't work
Summary: [3.4 Regression] -fwritable-strings doesn't work
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: 3.4.3
Assignee: Not yet assigned to anyone
Keywords: patch, wrong-code
Depends on:
Reported: 2004-10-24 19:44 UTC by Jakub Jelinek
Modified: 2004-10-31 14:28 UTC (History)
1 user (show)

See Also:
Target: x86_64-redhat-linux
Known to work:
Known to fail:
Last reconfirmed: 2004-10-24 19:56:22


Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2004-10-24 19:44:36 UTC
struct S { char *a, *b; };

extern void foo (struct S *);

main ()
  struct S s[] = {
    {"ABCDEFGH0123", "T"},
    {"ABCDEFGH4567", "T"},
    {"ABCDEFGH89ZYX", "T"},
    {"IJK012", "T"},
    {"IJK345", "T"},
    {"IJK678", "T"},
    {"IJKLMN", "T"},
    {"IJKOPQ", "T"},
    {0, 0}

  foo (s);
  return 0;

at -O2 -fwritable-strings results in 33 .data strings (one is "", so 32), while
the program has just 16 - everything is duplicated and only one copy is used.

With more strings in the table, the result is sometimes unlinkable due to
undefined .LCxxx symbols.

I'm very well aware that -fwritable-strings is deprecated, but either it should
be killed already in GCC 3.4.x, or it should work.
Comment 1 Andrew Pinski 2004-10-24 19:56:22 UTC

20030422 (236) between 20030504 (237)
Comment 2 Andrew Pinski 2004-10-24 20:31:55 UTC
Patch here: <>.
Comment 3 CVS Commits 2004-10-31 09:10:21 UTC
Subject: Bug 18129

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	2004-10-31 09:10:12

Modified files:
	gcc            : ChangeLog varasm.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: 20041024-1.c 

Log message:
	PR middle-end/18129
	* varasm.c (copy_constant): Don't copy STRING_CSTs if
	(build_constant_desc): Call copy_constant unconditionally.
	* gcc.dg/20041024-1.c: New test.


Comment 4 Giovanni Bajo 2004-10-31 10:24:32 UTC
Comment 5 Andrew Pinski 2004-10-31 14:28:15 UTC
Should have been closed.