This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/77357] strlen of constant strings not folded
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Aug 2016 14:22:36 +0000
- Subject: [Bug middle-end/77357] strlen of constant strings not folded
- Auto-submitted: auto-generated
- References: <bug-77357-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77357
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Sorry, wrong test case. Here's the right one:
const char a[] = "abc";
const char* const s = "abc";
void global_array (void)
{
if (__builtin_strlen (a) != 3)
__builtin_abort ();
}
void local_array (void)
{
static const char a[] = "abc";
if (__builtin_strlen (a) != 3)
__builtin_abort ();
}
void global_pointer (void)
{
if (__builtin_strlen (s) != 3)
__builtin_abort ();
}
void local_pointer (void)
{
static const char* const s = "abc";
if (__builtin_strlen (s) != 3)
__builtin_abort ();
}
struct X { char a [4]; };
const struct X x = { "abc" };
void global_struct (void)
{
if (__builtin_strlen (x.a) != 3)
__builtin_abort ();
}
void local_struct (void)
{
static const struct X x = { "abc" };
if (__builtin_strlen (x.a) != 3)
__builtin_abort ();
}