NUL termination in the first int_size_in_bytes (TREE_TYPE (decl))
rather than TREE_STRING_LENGTH bytes.
* gcc.dg/merge-all-constants-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114842
138bc75d-0d04-0410-961f-
82ee72b054a4
+2006-06-21 Jakub Jelinek <jakub@redhat.com>
+
+ * varasm.c (mergeable_string_section): Check for embedded NULs and
+ NUL termination in the first int_size_in_bytes (TREE_TYPE (decl))
+ rather than TREE_STRING_LENGTH bytes.
+
2006-06-21 Richard Guenther <rguenther@suse.de>
* ggc-page.c (extra_order_size_table): Add var_ann_d,
+2006-06-21 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.dg/merge-all-constants-1.c: New test.
+
2006-06-20 Janis Johnson <janis187@us.ibm.com>
PR c++/28113
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-w -O2 -fmerge-all-constants" } */
+
+const char str1[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
+const char str2[38] = "0123456789abcdefghijklmnopqrstuvwxyz";
+const char str3[10] = "0123456789abcdefghijklmnopqrstuvwxyz";
+
+/* { dg-final { scan-assembler-not "\.rodata\.str" } } */
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
{
+ HOST_WIDE_INT len;
+
if (HAVE_GAS_SHF_MERGE && flag_merge_constants
&& TREE_CODE (decl) == STRING_CST
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
&& align <= 256
- && TREE_STRING_LENGTH (decl) >= int_size_in_bytes (TREE_TYPE (decl)))
+ && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
+ && TREE_STRING_LENGTH (decl) >= len)
{
enum machine_mode mode;
unsigned int modesize;
const char *str;
- int i, j, len, unit;
+ HOST_WIDE_INT i;
+ int j, unit;
char name[30];
mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
align = modesize;
str = TREE_STRING_POINTER (decl);
- len = TREE_STRING_LENGTH (decl);
unit = GET_MODE_SIZE (mode);
/* Check for embedded NUL characters. */