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

            Bug ID: 65111
           Summary: null checks on pointers created from references not
                    optimized away
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: froydnj at gcc dot gnu.org

Compiling the C++ code:

#include <new>

void init(int& p)
{
  new (&p) float(3.14f);
}

yields (GCC 4.9.1):

_Z4initRi:
    testq    %rdi, %rdi
    je    .L1
    movl    $0x4048f5c3, (%rdi)
.L1:
    rep ret

Compiling the equivalent code with clang (3.5 and 3.6-prerelease) yields:

_Z4initRi:                              # @_Z4initRi
    movl    $1078523331, (%rdi)     # imm = 0x4048F5C3
    retq

because clang has determined that &p cannot be null.

Reply via email to