public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/112716] New: LTO optimization with struct of variable ssize
@ 2023-11-26 17:46 muecker at gwdg dot de
  2023-11-26 17:54 ` [Bug lto/112716] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: muecker at gwdg dot de @ 2023-11-26 17:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112716

            Bug ID: 112716
           Summary: LTO optimization with struct of variable ssize
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

The following code using a GNU extension gets miscompiled due to incorrect
aliasing assumptions with -flto and -O2: 

gcc -flto -O2 y.c y2.c  -DT1="int[n]" -DT2="int[n]"
// y.c
void bar(void*);

[[gnu::noinline,gnu::noipa]]
int foo(void *p, void *q)
{
        int n = 5;
        struct foo { int x; typeof(T1) y; } *p2 = p;
        p2->x = 1;
        bar(q);
        return p2->x;
}

int main()
{
        int n = 5;
        void *p = __builtin_malloc(sizeof(struct foo { int x; typeof(T1) y;
}));

        if (!p)
                return 0;

        if (2 != foo(p, p))
                __builtin_abort();

        return 0;
}
// y2
void bar(void* q)
{       
        int n = 5;
        struct foo { int x; typeof(T2) y; } *q2 = q;
        q2->x = 2;
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-11-28 15:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-26 17:46 [Bug lto/112716] New: LTO optimization with struct of variable ssize muecker at gwdg dot de
2023-11-26 17:54 ` [Bug lto/112716] " pinskia at gcc dot gnu.org
2023-11-26 18:17 ` uecker at gcc dot gnu.org
2023-11-26 18:26 ` sjames at gcc dot gnu.org
2023-11-27  8:13 ` [Bug lto/112716] LTO optimization with struct with variable size rguenth at gcc dot gnu.org
2023-11-27 14:00 ` muecker at gwdg dot de
2023-11-27 14:26 ` rguenther at suse dot de
2023-11-27 15:47 ` uecker at gcc dot gnu.org
2023-11-28  8:02 ` rguenth at gcc dot gnu.org
2023-11-28 15:19 ` muecker at gwdg dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).