From: Richard Biener Date: Wed, 18 Jan 2023 13:54:33 +0000 (+0100) Subject: lto/108445 - avoid LTO decl wrapping being confused by tree sharing X-Git-Tag: basepoints/gcc-14~1965 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4abe5c456a3023f61c3e053255b7dd72ca0d7ec;p=thirdparty%2Fgcc.git lto/108445 - avoid LTO decl wrapping being confused by tree sharing r13-4743 exposed more tree sharing which runs into a latent issue with LTO decl wrapping during streaming. The following adds a testcase triggering the issue. PR lto/108445 * gcc.dg/lto/pr108445_0.c: New testcase. * gcc.dg/lto/pr108445_1.c: Likewise. --- diff --git a/gcc/testsuite/gcc.dg/lto/pr108445_0.c b/gcc/testsuite/gcc.dg/lto/pr108445_0.c new file mode 100644 index 000000000000..06dac691e84b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr108445_0.c @@ -0,0 +1,4 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { "-g -O2 -flto" } } */ + +int gArray[16]; diff --git a/gcc/testsuite/gcc.dg/lto/pr108445_1.c b/gcc/testsuite/gcc.dg/lto/pr108445_1.c new file mode 100644 index 000000000000..50db9feb8a5f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr108445_1.c @@ -0,0 +1,19 @@ +extern int gArray[]; + +int foo(int *a) +{ + int *p = a; + + return *p; +} + +int main(int argc, char *argv[]) +{ + if (argc & 1) + gArray[argc - 1] = 1; + + if (argc > 1) + return foo(gArray); + + return 0; +}