[Bug c/95189] New: memcmp being wrongly stripped (regression)

gcc at pkh dot me gcc-bugzilla@gcc.gnu.org
Mon May 18 13:56:37 GMT 2020


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

            Bug ID: 95189
           Summary: memcmp being wrongly stripped (regression)
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at pkh dot me
  Target Milestone: ---

Given the following C code:

    % cat a.c
    #include <string.h>
    static const float z[1] = {0};
    int f(float x) { return memcmp(&x, z, sizeof(x)); }

GCC 10 generates this on x86-64:

    % gcc -Wall -O2 -c a.c && objdump -d -Mintel a.o

    a.o:     file format elf64-x86-64


    Disassembly of section .text:

    0000000000000000 <f>:
       0:       f3 0f 11 44 24 fc       movss  DWORD PTR [rsp-0x4],xmm0
       6:       0f b6 44 24 fc          movzx  eax,BYTE PTR [rsp-0x4]
       b:       c3                      ret

This doesn't happen if "= {0}" is removed from the z initialization (wtf?).
It also doesn't happen with -O1.


More information about the Gcc-bugs mailing list