Bug 13361 - const wchar_t * strings not stored in pch
Summary: const wchar_t * strings not stored in pch
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Geoff Keating
URL:
Keywords: wrong-code
Depends on: 13750
Blocks:
  Show dependency treegraph
 
Reported: 2003-12-08 21:42 UTC by Thomas J. Francis, Jr.
Modified: 2004-09-18 06:45 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-01-12 23:17:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas J. Francis, Jr. 2003-12-08 21:42:10 UTC
This is using gcc (GCC) 3.4 20031203 (experimental):
-------------
%cat test.hh
#include <stdio.h>

const char test_var2[] = "normal string";
const wchar_t test_var[] = L"wide string";

%cat test.cpp
#include "test.hh"

int main(int argc, char **argv)
{
   printf("wide: %S\r\n", test_var);
   printf("normal: %s\r\n", test_var2);

   return 0;
}
-----

Create test.hh.gch using:

%g++ test.hh

Create testprog using:

%g++ -o testprog test.cc

The output of testprog is:

wide: 
normal: normal string

If I remove test.hh.gch, and then recompile testprog, the output is:

wide: wide string
normal: normal string
Comment 1 Andrew Pinski 2003-12-08 23:02:35 UTC
Confirmed (the C front-end is right).

The header file should have #include <wchar.h> in it.
Comment 2 Andrew Pinski 2003-12-09 07:46:01 UTC
Looks like for some reason the C++ front-end is defering the output of const wchar_t 
unlike the C front-end and unlike the const char also.
Comment 3 Geoff Keating 2004-01-12 23:17:58 UTC
Confirmed on powerpc-darwin.
Comment 4 GCC Commits 2004-01-16 07:20:41 UTC
Subject: Bug 13361

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	geoffk@gcc.gnu.org	2004-01-16 07:20:38

Modified files:
	gcc            : ChangeLog c-typeck.c dwarf2out.c stmt.c tree.c 
	                 tree.def tree.h 
	gcc/config/sh  : sh.c 
	gcc/cp         : ChangeLog lex.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/pch: wchar-1.C wchar-1.Hs 

Log message:
	Index: ChangeLog
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	
	PR pch/13361
	* c-typeck.c (constructor_asmspec): Delete.
	(struct initializer_stack): Delete field 'asmspec'.
	(start_init): Delete saving of asmspec.
	(finish_init): Don't update constructor_asmspec.
	* dwarf2out.c (rtl_for_decl_location): Duplicate string from tree.
	* stmt.c (expand_asm): Duplicate strings from tree.
	(expand_asm_operands): Likewise.
	* tree.c (tree_size): Update computation of size of STRING_CST.
	(make_node): Don't make STRING_CST nodes.
	(build_string): Allocate string with tree node.
	* tree.def (STRING_CST): Update comment.
	* tree.h (TREE_STRING_POINTER): Adjust for change to STRING_CST.
	(tree_string): Place contents of string in tree node.
	* config/sh/sh.c (sh_handle_sp_switch_attribute): Duplicate string
	from tree.
	
	Index: cp/ChangeLog
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	
	PR pch/13361
	* cp/lex.c (handle_pragma_interface): Duplicate string from tree.
	(handle_pragma_implementation): Likewise.
	
	Index: testsuite/ChangeLog
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	
	PR pch/13361
	* testsuite/g++.dg/pch/wchar-1.C: New.
	* testsuite/g++.dg/pch/wchar-1.Hs: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2318&r2=2.2319
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.271&r2=1.272
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dwarf2out.c.diff?cvsroot=gcc&r1=1.476&r2=1.477
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stmt.c.diff?cvsroot=gcc&r1=1.341&r2=1.342
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.341&r2=1.342
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.def.diff?cvsroot=gcc&r1=1.69&r2=1.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.457&r2=1.458
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&r1=1.246&r2=1.247
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3885&r2=1.3886
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&r1=1.322&r2=1.323
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3382&r2=1.3383
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.Hs.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Geoff Keating 2004-01-16 07:22:41 UTC
That should have fixed it.
Comment 6 GCC Commits 2004-02-05 21:56:49 UTC
Subject: Bug 13361

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ro@gcc.gnu.org	2004-02-05 21:56:43

Modified files:
	gcc            : ChangeLog c-typeck.c dwarf2out.c stmt.c tree.c 
	                 tree.def tree.h 
	gcc/config/sh  : sh.c 
	gcc/cp         : ChangeLog lex.c 
	gcc/testsuite  : ChangeLog 
Removed files:
	gcc/testsuite/g++.dg/pch: wchar-1.C wchar-1.Hs 

Log message:
	PR middle-end/13750
	Revert:
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	PR pch/13361
	* c-typeck.c (constructor_asmspec): Delete.
	(struct initializer_stack): Delete field 'asmspec'.
	(start_init): Delete saving of asmspec.
	(finish_init): Don't update constructor_asmspec.
	* dwarf2out.c (rtl_for_decl_location): Duplicate string from tree.
	* stmt.c (expand_asm): Duplicate strings from tree.
	(expand_asm_operands): Likewise.
	* tree.c (tree_size): Update computation of size of STRING_CST.
	(make_node): Don't make STRING_CST nodes.
	(build_string): Allocate string with tree node.
	* tree.def (STRING_CST): Update comment.
	* tree.h (TREE_STRING_POINTER): Adjust for change to STRING_CST.
	(tree_string): Place contents of string in tree node.
	* config/sh/sh.c (sh_handle_sp_switch_attribute): Duplicate string
	from tree.
	
	cp:
	PR middle-end/13750
	Revert:
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	PR pch/13361
	* cp/lex.c (handle_pragma_interface): Duplicate string from tree.
	(handle_pragma_implementation): Likewise.
	
	testsuite:
	PR middle-end/13750
	Revert:
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	PR pch/13361
	* testsuite/g++.dg/pch/wchar-1.C: New.
	* testsuite/g++.dg/pch/wchar-1.Hs: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2659&r2=2.2660
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.275&r2=1.276
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dwarf2out.c.diff?cvsroot=gcc&r1=1.484&r2=1.485
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stmt.c.diff?cvsroot=gcc&r1=1.345&r2=1.346
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.345&r2=1.346
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.def.diff?cvsroot=gcc&r1=1.70&r2=1.71
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.461&r2=1.462
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&r1=1.255&r2=1.256
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3940&r2=1.3941
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&r1=1.323&r2=1.324
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.C.diff?cvsroot=gcc&r1=1.1&r2=NONE
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.Hs.diff?cvsroot=gcc&r1=1.1&r2=NONE
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3473&r2=1.3474

Comment 7 GCC Commits 2004-02-05 22:01:47 UTC
Subject: Bug 13361

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	ro@gcc.gnu.org	2004-02-05 22:01:42

Modified files:
	gcc            : ChangeLog c-typeck.c dwarf2out.c stmt.c tree.c 
	                 tree.def tree.h 
	gcc/config/sh  : sh.c 
	gcc/cp         : ChangeLog lex.c 
	gcc/testsuite  : ChangeLog 
Removed files:
	gcc/testsuite/g++.dg/pch: wchar-1.C wchar-1.Hs 

Log message:
	PR middle-end/13750
	Revert:
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	PR pch/13361
	* c-typeck.c (constructor_asmspec): Delete.
	(struct initializer_stack): Delete field 'asmspec'.
	(start_init): Delete saving of asmspec.
	(finish_init): Don't update constructor_asmspec.
	* dwarf2out.c (rtl_for_decl_location): Duplicate string from tree.
	* stmt.c (expand_asm): Duplicate strings from tree.
	(expand_asm_operands): Likewise.
	* tree.c (tree_size): Update computation of size of STRING_CST.
	(make_node): Don't make STRING_CST nodes.
	(build_string): Allocate string with tree node.
	* tree.def (STRING_CST): Update comment.
	* tree.h (TREE_STRING_POINTER): Adjust for change to STRING_CST.
	(tree_string): Place contents of string in tree node.
	* config/sh/sh.c (sh_handle_sp_switch_attribute): Duplicate string
	from tree.
	
	cp:
	PR middle-end/13750
	Revert:
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	PR pch/13361
	* cp/lex.c (handle_pragma_interface): Duplicate string from tree.
	(handle_pragma_implementation): Likewise.
	
	testsuite:
	PR middle-end/13750
	Revert:
	2004-01-15  Geoffrey Keating  <geoffk@apple.com>
	PR pch/13361
	* testsuite/g++.dg/pch/wchar-1.C: New.
	* testsuite/g++.dg/pch/wchar-1.Hs: New.

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.147&r2=2.2326.2.148
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.272&r2=1.272.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dwarf2out.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.478.2.2&r2=1.478.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stmt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.342&r2=1.342.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.342.2.2&r2=1.342.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.def.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.70&r2=1.70.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.458.2.2&r2=1.458.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.247.2.2&r2=1.247.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.39&r2=1.3892.2.40
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.323&r2=1.323.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=NONE
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.Hs.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=NONE
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.54&r2=1.3389.2.55

Comment 8 Andrew Pinski 2004-02-06 02:46:43 UTC
Reopening as this had to be reverted.
Comment 9 Geoff Keating 2004-02-06 20:48:01 UTC
Assigning to person who reintroduced the bug.

Suggested fix:

1. Work out what's wrong on tru64
2. Fix it
3. Re-install patch.
Comment 10 Andrew Pinski 2004-04-05 17:23:30 UTC
Note the Tru64 problem is recorded in PR 13750.
Comment 11 Geoff Keating 2004-06-04 22:07:40 UTC
Is there any progress on this bug?
Comment 12 Mark Mitchell 2004-06-09 19:23:23 UTC
Rainer --

What's the status here?

-- Mark
Comment 13 Rainer Orth 2004-06-09 19:30:48 UTC
Subject: Re:  const wchar_t * strings not stored in pch

mmitchel at gcc dot gnu dot org writes:

> What's the status here?

I didn't have much time for gcc work lately.  Besides, when I pointed out
the regression caused by the original patch in PR target/13750, Geoff's
only reaction to my request for help (not being a target maintainer, but
only interested to keep my platforms regression-free) was: find the target
bug and fix it.  Without lots of help, this is way beyond my capabilities.

	Rainer
Comment 14 Mark Mitchell 2004-06-18 23:45:45 UTC
Postponed until GCC 3.4.2.

Geoff, it would be nice if you would help Rainer solve this problem.  We
shouldn't have to choose between supporting that platform and having PCH that
works with wide-character literals, and it's going to be really hard for him to
work this out by himself.
Comment 15 Geoff Keating 2004-06-19 00:10:57 UTC
Subject: Re:  const wchar_t * strings not stored in pch


On 18/06/2004, at 4:45 PM, mmitchel at gcc dot gnu dot org wrote:

> Postponed until GCC 3.4.2.
>
> Geoff, it would be nice if you would help Rainer solve this problem.  
> We
> shouldn't have to choose between supporting that platform and having 
> PCH that
> works with wide-character literals, and it's going to be really hard 
> for him to
> work this out by himself.

I believe that this is a problem in the Alpha backend (which I don't 
know much about) or in the system C library on Tru64 (which I know 
nothing at all about, and don't have access to); and exposing it 
requires building Ada (which I can't do, and don't know about) on Tru64 
(which I don't have access to).  But given those constraints, I'd be 
happy to give any help I can.

I'd suggest, though, that if we want to support Ada on Tru64-alpha, 
that we should have someone who *does* have access to the platform and 
*can* solve problems like these.

Comment 16 Mark Mitchell 2004-08-29 17:57:09 UTC
Postponed until GCC 3.4.3.
Comment 17 Geoff Keating 2004-09-16 23:40:48 UTC
Taking over this bug, to give it a chance of being fixed for 4.0.
Comment 18 GCC Commits 2004-09-18 05:50:57 UTC
Subject: Bug 13361

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	geoffk@gcc.gnu.org	2004-09-18 05:50:52

Modified files:
	gcc            : ChangeLog c-typeck.c dwarf2out.c stmt.c 
	                 tree-inline.c tree.c tree.def tree.h 
	gcc/config/sh  : sh.c 
	gcc/cp         : ChangeLog lex.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/pch: wchar-1.C wchar-1.Hs 

Log message:
	* tree-inline.c (copy_tree_r): Don't duplicate constants, they're
	shared anyway.
	
	PR pch/13361
	* c-typeck.c (constructor_asmspec): Delete.
	(struct initializer_stack): Delete field 'asmspec'.
	(start_init): Delete saving of asmspec.
	(finish_init): Don't update constructor_asmspec.
	* dwarf2out.c (rtl_for_decl_location): Duplicate string from tree.
	* stmt.c (expand_asm): Duplicate strings from tree.
	(expand_asm_operands): Likewise.
	* tree.c (tree_size): Update computation of size of STRING_CST.
	(make_node): Don't make STRING_CST nodes.
	(build_string): Allocate string with tree node.
	(tree_code_size): Clean up assertions, don't allow requests
	for "the size of a STRING_CST".
	* tree.def (STRING_CST): Update comment.
	* tree.h (TREE_STRING_POINTER): Adjust for change to STRING_CST.
	(tree_string): Place contents of string in tree node.
	* config/sh/sh.c (sh_handle_sp_switch_attribute): Duplicate string
	from tree.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5508&r2=2.5509
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.374&r2=1.375
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dwarf2out.c.diff?cvsroot=gcc&r1=1.546&r2=1.547
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stmt.c.diff?cvsroot=gcc&r1=1.394&r2=1.395
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&r1=1.141&r2=1.142
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.432&r2=1.433
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.def.diff?cvsroot=gcc&r1=1.99&r2=1.100
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.624&r2=1.625
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&r1=1.299&r2=1.300
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4362&r2=1.4363
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&r1=1.345&r2=1.346
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4311&r2=1.4312
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pch/wchar-1.Hs.diff?cvsroot=gcc&r1=1.2&r2=1.3

Comment 19 Geoff Keating 2004-09-18 06:45:15 UTC
This should be fixed again now.