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

            Bug ID: 102579
           Summary: Failure to optimize out allocation if volatile read is
                    present in the middle
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

void test_unused() {
  volatile int d;
  int *p = new int;
  d;
  delete p;
}

This can be optimized to just reading `d` once. LLVM does this optimization,
but GCC does not.

Reply via email to