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

            Bug ID: 117002
           Summary: lifetime.d: In function ‘_d_newclassT’: error: size of
                    array element is not a multiple of its alignment with
                    -Warray-bounds and -O2
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: a.horodniceanu at proton dot me
  Target Milestone: ---

Reported first at https://bugs.gentoo.org/940750 and reduced to:
------
module object;

extern(C++) class Foo {
        ubyte[4] not_multiple_of_8;
}

extern(C)
int main () {
    // avoid optimizations
    void* p = cast(void*)(0xdeadbeef);
    auto init = __traits(initSymbol, Foo);

    p[0 .. init.length] = init[];
    return 0;
}
------
Compile with:
------
$ gdc repro.d -Warray-bounds -O2
/root/repro.d: In function ‘main’:
/root/repro.d:8:5: error: size of array element is not a multiple of its
alignment
    8 | int main () {
      |     ^
------

The code is a reduction of _d_newclassT in core/lifetime.d with the original
error being:
------
$ cat repro.d
class Foo {
        ubyte[4] not_multiple_of_8;
}

void foo () {
        new Foo();
}
$ gdc repro.d -Warray-bounds -O2
/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/d/core/lifetime.d: In function
‘_d_newclassT’:
/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/d/core/lifetime.d:2725:3: error:
size of array element is not a multiple of its alignment
 2725 | T _d_newclassT(T)() @trusted
      |   ^
------

Reply via email to