[Bug c++/90947] [9/10 Regression] Simple lookup table of array of strings is miscompiled
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 20 15:24:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90947
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |ASSIGNED
Keywords| |wrong-code
Last reconfirmed| |2019-06-20
CC| |msebor at gcc dot gnu.org
Resolution|DUPLICATE |---
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=89980
Ever confirmed|0 |1
Summary|Simple lookup table of |[9/10 Regression] Simple
|array of strings is |lookup table of array of
|miscompiled |strings is miscompiled
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
This is actually a different bug in the same commit. A simpler test case is
this:
void f (void)
{
const char* a[2][2] = {
{ "0", "1" },
{ "", 0 }
};
if (!a[1][0]) // should be folded to false with -O
__builtin_abort ();
}
There is code in place to handle this kind of initialization:
/* Pointers initialized to strings must be treated as non-zero
even if the string is empty. */
tree init_type = TREE_TYPE (elt_init);
if ((POINTER_TYPE_P (elt_type) != POINTER_TYPE_P (init_type))
|| !initializer_zerop (elt_init))
last_nonzero = index;
This was added in r270177 to fix pr89980. Unfortunately, the handling is
incomplete and the test insufficient to expose it.
More information about the Gcc-bugs
mailing list