Skip to content

Aligned Allocation #2437

Description

@philip-paul-mueller

While working on the nanobind interface my friend found an error related to gcc16 that is now a hard error.

The error is related to the following construct:

mid_deg = new double DACE_ALIGN(64)[2];

(dace/codegen/targets/cpu.py:492 and :541), where DACE_ALIGN(N) expands to __attribute__((aligned(N))) on GCC/Clang (dace/runtime/include/dace/types.h).

A small test program:

int main() {
    double *p = new double __attribute__((aligned(64)))[2];  // error on GCC 16
    delete[] p;
}

fails with the error:

test.cpp: In function »int main()«:
test.cpp:2:58: error: Ausrichtung der Arrayelemente ist größer als die Elementgröße
    2 |     double *p = new double __attribute__((aligned(64)))[2];  // error on GCC 16
      |                                                          ^

However, it only affects allocations of known small size.

According to my friend the annotation also does not have an effect.
If the alignment of the allocation should be controlled then std::align_val_t new expressions a C++17 feature must be used.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions