On Sat, 27 Aug 2011, rguenth at gcc dot gnu.org wrote: > Hmmm. Partitioning unshares string constants and I suppose ipa-cp propagates > one of it to the callee. > > Not sure if this is a well-defined testcase though. If it is we'd probably > need to add CONST_DECLs for address-taken constants and register them with > the varpool (and disallow &"..." in gimple). > > It should be possible to make a non-LTO testcase that fails similarly > by instructing the assembler/linker not to merge strings. > > Joseph, does C require that a string literal "..." has a single underlying > object or would the testcase be undefined?
It's completely clear that once a pointer to a string literal has been assigned to a variable, that variable has a well-defined value pointing to that particular copy of the string literal, and so compares equal to itself. So the testcase ought to pass. I believe each instance of a string literal in the source code after preprocessing corresponds to just one object of static storage duration (so the values from different calls to the same function containing a string literal must also compare equal, for example) though the objects from separate string literals in the source code may or may not overlap or coincide. (There is no requirement for, or restriction against, unification between copies of the same inline function included in different translation units.) So the value of "foo" == "foo" is unspecified, but given const char *return_foo (void) { return "foo"; } the value of return_foo () == return_foo () must be 1. -- Joseph S. Myers jos...@codesourcery.com