STRING_CST nodes with embedded nuls are formatted in Gimple dumps only up to the first nul. Characters beyond the first nul are not printed. This makes the dumps incomplete (and raises the question of whether the code is even correct.) This has recently been exacerbated by transforming braced-list initialized constant character arrays into STRING_CSTs (r263511). $ cat f.c && gcc -O2 -S -Wall -fdump-tree-gimple=/dev/stdout f.c void f (char *d) { const char a[3] = "\000ab"; __builtin_strcpy (d, a); } void g (char *d) { const char a[] = { 0, 'a', 'b', 'b' }; __builtin_strcpy (d, a); } f (char * d) { const char a[3]; try { a = ""; __builtin_strcpy (d, &a); } finally { a = {CLOBBER}; } } g (char * d) { const char a[4]; try { a = ""; __builtin_strcpy (d, &a); } finally { a = {CLOBBER}; } }
Patch: https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01324.html
Patch committed in r263781.
Author: msebor Date: Wed Aug 22 16:42:56 2018 New Revision: 263781 URL: https://gcc.gnu.org/viewcvs?rev=263781&root=gcc&view=rev Log: PR middle-end/87052 - STRING_CST printing incomplete in Gimple dumps gcc/testsuite/ChangeLog: PR middle-end/87052 * gcc.dg/pr87052.c: New test. * gcc.dg/tree-ssa/dump-3.c: Adjust. gcc/ChangeLog: PR middle-end/87052 * tree-pretty-print.c (pretty_print_string): Add argument. (dump_generic_node): Call to pretty_print_string with string size. Added: trunk/gcc/testsuite/gcc.dg/pr87052.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/tree-ssa/dump-3.c trunk/gcc/tree-pretty-print.c
Done in r263781.