[Bug c/105588] New: _Alignof (C) and alignof (C++) on dereference of `double *` disagree on 32-bit x86

hstong at ca dot ibm.com gcc-bugzilla@gcc.gnu.org
Fri May 13 00:16:44 GMT 2022


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

            Bug ID: 105588
           Summary: _Alignof (C) and alignof (C++) on dereference of
                    `double *` disagree on 32-bit x86
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

_Alignof(expression) on a dereference of a pointer to double of unknown value
should produce the ABI-required alignment and not the preferred alignment.

The equivalent C++ program behaves as expected.
Online compiler link: https://godbolt.org/z/Tb93a6fcT

### SOURCE (<stdin>):
void f(double *pd) {
  extern char x[_Alignof(double)];
  char (*y)[_Alignof(*pd)] = &x;
}


### COMPILER INVOCATION COMMAND:
gcc -m32 -fsyntax-only -xc -


### ACTUAL OUTPUT:
<stdin>: In function 'f':
<stdin>:3:30: warning: initialization of 'char (*)[8]' from incompatible
pointer type 'char (*)[4]' [-Wincompatible-pointer-types]


### EXPECTED OUTPUT:
(No "incompatible pointer types" warning)


### COMPILER VERSION INFO (`gcc -v`):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/gcc
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220511 (experimental) (GCC)


More information about the Gcc-bugs mailing list