struct S { char *a, *b; }; extern void foo (struct S *); int 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.
Confirmed. 20030422 (236) between 20030504 (237)
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02020.html>.
Subject: Bug 18129 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: jakub@gcc.gnu.org 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 flag_writable_strings. (build_constant_desc): Call copy_constant unconditionally. * gcc.dg/20041024-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.678&r2=2.2326.2.679 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.405.2.3&r2=1.405.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.302&r2=1.3389.2.303 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20041024-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed.
Should have been closed.