public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97739] New: alignas() fails to compile with const expression like std::max or std::min
@ 2020-11-06  8:58 stanislav.pikulik at lge dot com
  2020-11-06  9:19 ` [Bug c++/97739] " jakub at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: stanislav.pikulik at lge dot com @ 2020-11-06  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97739
           Summary: alignas() fails to compile with const expression like
                    std::max or std::min
           Product: gcc
           Version: 8.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stanislav.pikulik at lge dot com
  Target Milestone: ---

#include <algorithm>

template <typename T>
constexpr T foo(T arg) { return arg; }

template <typename T>
constexpr auto bar(T arg1, T arg2) { return arg1>arg2 ? arg1 : arg2; }

int main()
{
  alignas(foo(2)) char a1[3];          // ok
  alignas(bar(1,2)) char a2[3];        // ok

  const size_t b3 = std::max(1,2);
  alignas(b3) char a3[3];              // ok

  constexpr size_t b4 = std::max(1,2);
  alignas(b4) char a4[3];              // ok

  alignas(std::max(1,2)) char a5[3];   // error: requested alignment is not an
integer constant

  return 0;
}

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

* [Bug c++/97739] alignas() fails to compile with const expression like std::max or std::min
  2020-11-06  8:58 [Bug c++/97739] New: alignas() fails to compile with const expression like std::max or std::min stanislav.pikulik at lge dot com
@ 2020-11-06  9:19 ` jakub at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-06  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Dup of an already fixed bug.

*** This bug has been marked as a duplicate of bug 90736 ***

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

end of thread, other threads:[~2020-11-06  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06  8:58 [Bug c++/97739] New: alignas() fails to compile with const expression like std::max or std::min stanislav.pikulik at lge dot com
2020-11-06  9:19 ` [Bug c++/97739] " jakub 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).