[PATCH] fix a couple of bugs in const string folding (PR 86532)
Bernd Edlinger
bernd.edlinger@hotmail.de
Fri Jul 20 21:11:00 GMT 2018
I think I have found a valid test case where the latest patch
does generate invalid code:
$ cat part.c
static const char a[3][8] = { "1234", "12345", "123456" };
int main ()
{
volatile int i = 1;
int n = __builtin_strlen (*(&a[1]+i));
if (n != 6)
__builtin_abort ();
}
$ gcc part.c -fdump-tree-original
$ ./a.out
Aborted (core dumped)
$ cat part.c.004t.original
;; Function main (null)
;; enabled by -tree-original
{
volatile int i = 1;
int n = (ssizetype) (SAVE_EXPR <(long unsigned int) i * 8>) <= 5 ? (int) (5 - (unsigned int) (SAVE_EXPR <(long unsigned int) i * 8>)) : 0;
volatile int i = 1;
int n = (ssizetype) (SAVE_EXPR <(long unsigned int) i * 8>) <= 5 ? (int) (5 - (unsigned int) (SAVE_EXPR <(long unsigned int) i * 8>)) : 0;
if (n != 6)
{
__builtin_abort ();
}
}
return 0;
string_constant is called with arg = (const char *) (&a[1] + (sizetype) ((long unsigned int) i * 8))
Bernd.
More information about the Gcc-patches
mailing list