diff options
author | Martin Sebor <msebor@redhat.com> | 2021-11-16 09:18:25 -0700 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-11-16 09:18:25 -0700 |
commit | ba6e17e78db543b336c196b55fa6430e513f1941 (patch) | |
tree | 834fa5781c510ed696423f889b3bcc46572f9729 /gcc/testsuite | |
parent | 0002a8a1997c7beb3c4facc17ed0d1294e3dce14 (diff) | |
download | gcc-ba6e17e78db543b336c196b55fa6430e513f1941.zip gcc-ba6e17e78db543b336c196b55fa6430e513f1941.tar.gz gcc-ba6e17e78db543b336c196b55fa6430e513f1941.tar.bz2 |
Avoid assuming maximum string length is constant [PR102960].
Resolves:
PR tree-optimization/102960 - ICE: in sign_mask, at wide-int.h:855 in GCC 10.3.0
gcc/ChangeLog:
PR tree-optimization/102960
* gimple-fold.c (get_range_strlen): Take bitmap as an argument rather
than a pointer to it.
(get_range_strlen_tree): Same. Remove bitmap allocation. Use
an auto_bitmap.
(get_maxval_strlen): Use an auto_bitmap.
* tree-ssa-strlen.c (get_range_strlen_dynamic): Factor out PHI
handling...
(get_range_strlen_phi): ...into this function.
Avoid assuming maximum string length is constant
(printf_strlen_execute): Dump pointer query cache contents when
details are requisted.
gcc/testsuite/ChangeLog:
PR tree-optimization/102960
* gcc.dg/Wstringop-overflow-84.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstringop-overflow-84.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-84.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-84.c new file mode 100644 index 0000000..2c0f507 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-84.c @@ -0,0 +1,15 @@ +/* PR middle-end/102960 - ICE: in sign_mask, at wide-int.h:855 in GCC 10.3.0 + { dg-do compile } + { dg-options "-Og -Wall" } */ + +void f (int i) +{ + const char *s; + if (i) + s = &"abcd"[i]; + + __builtin_printf ("%s", s); +} + +/* The use of s in the call to sprintf should result in: + { dg-prune-output "-Wmaybe-uninitialized" } */ |