On 10/03/18 18:31, Jeff Law wrote: >> - && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0 >> - && TREE_STRING_LENGTH (decl) >= len) >> + && (len = int_size_in_bytes (TREE_TYPE (decl))) >= 0 >> + && TREE_STRING_LENGTH (decl) == len) > Not sure why you want to test for >= 0 here. > 0 seems sufficient, > though I guess there's no harm in the = 0 case. >
Aehm, cough... Sorry Jeff, I need to change that back. It turns out that completely empty strings don't work right, because of this check in output_constant: output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align, bool reverse, bool merge_strings) { enum tree_code code; unsigned HOST_WIDE_INT thissize; rtx cst; if (size == 0 || flag_syntax_only) return size; So while my intention was to add a null-termination for all strings, including empty ones, this does not work for empty strings, which was diagnosed by the solaris assembler/linker. However since those empty strings do not use any space, there is no improvement by merging them in the first place. Rainer bootstrapped the attached patch successfully. Is it OK for trunk? Thanks Bernd.
2018-10-09 Bernd Edlinger <bernd.edlin...@hotmail.de> * varasm.c (mergeable_string_section): Don't try to move zero-length strings to the merge section. Index: gcc/varasm.c =================================================================== --- gcc/varasm.c (revision 264887) +++ gcc/varasm.c (working copy) @@ -804,7 +804,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUS && TREE_CODE (decl) == STRING_CST && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE && align <= 256 - && (len = int_size_in_bytes (TREE_TYPE (decl))) >= 0 + && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0 && TREE_STRING_LENGTH (decl) == len) { scalar_int_mode mode;