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

            Bug ID: 104177
           Summary: [diagnostic] basic.align#9 should emit diagnostic for
                    unsupported alignas
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldalessandro at gmail dot com
  Target Milestone: ---

Created attachment 52264
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52264&action=edit
Downloaded CE example.

It appears that gcc doesn't currently support extended alignment for locals in
coroutine frames.

I believe this is **not** a bug, as I think that such extended alignment
support is implementation defined, however I believe that
https://timsong-cpp.github.io/cppwp/n4861/basic.align#9 says that a program
that requests unsupported extended alignment is ill-formed, and thus should get
a diagnostic.

Given the infrastructure required to demonstrate this bug, it's difficult for
me to provide a self contained example, however given the std::generator
support proposed in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2168r3.pdf, and
implemented in https://godbolt.org/z/T58h1W, the failure is:

  #include <cassert>
  #include <cstddef>
  #include <cstdint>
  #include <cstdio>

  struct alignas(32) Foo {
  };

  static std::generator<const uint64_t> foo() {
      Foo m{};
      fprintf(stdout, "%lu\n", uintptr_t(&m) % alignof(Foo));
      fflush(stdout);
      assert(uintptr_t(&m) % alignof(Foo) == 0);
      co_yield 1;
  }

  int main() {
      for (auto && x : foo()) {
          return x;
      }
  }

CE link: https://godbolt.org/z/GTKPa81W8

Originally came to my attention in a discussion with
https://github.com/bniehoff.

Reply via email to