public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104177] New: [diagnostic] basic.align#9 should emit diagnostic for unsupported alignas
@ 2022-01-22  1:59 ldalessandro at gmail dot com
  2022-01-22  2:02 ` [Bug c++/104177] " ldalessandro at gmail dot com
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: ldalessandro at gmail dot com @ 2022-01-22  1:59 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-04-30 19:42 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22  1:59 [Bug c++/104177] New: [diagnostic] basic.align#9 should emit diagnostic for unsupported alignas ldalessandro at gmail dot com
2022-01-22  2:02 ` [Bug c++/104177] " ldalessandro at gmail dot com
2022-01-22  2:04 ` pinskia at gcc dot gnu.org
2022-01-22  2:05 ` pinskia at gcc dot gnu.org
2022-01-22  2:07 ` ldalessandro at gmail dot com
2022-01-22  2:22 ` pinskia at gcc dot gnu.org
2022-01-22  3:48 ` pinskia at gcc dot gnu.org
2022-01-22  3:48 ` pinskia at gcc dot gnu.org
2022-01-22  4:08 ` [Bug c++/104177] coroutine frame is not being allocated with the correct alignment pinskia at gcc dot gnu.org
2022-01-22  4:14 ` pinskia at gcc dot gnu.org
2022-01-22  4:18 ` pinskia at gcc dot gnu.org
2022-01-22  4:19 ` pinskia at gcc dot gnu.org
2022-01-22  4:20 ` pinskia at gcc dot gnu.org
2022-01-28 20:49 ` iains at gcc dot gnu.org
2022-01-28 21:10 ` ldalessandro at gmail dot com
2023-01-21  6:50 ` davidledger at live dot com.au
2023-01-21  6:51 ` davidledger at live dot com.au
2023-01-23  7:30 ` pinskia at gcc dot gnu.org
2023-01-23  7:33 ` pinskia at gcc dot gnu.org
2023-01-23  7:39 ` pinskia at gcc dot gnu.org
2023-01-23  9:02 ` davidledger at live dot com.au
2023-08-10  7:37 ` pinskia at gcc dot gnu.org
2024-04-30 19:42 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).