public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58109] New: alignas() fails to compile with constant expression
@ 2013-08-09 12:37 janezz55 at gmail dot com
  2013-08-09 12:59 ` [Bug c++/58109] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: janezz55 at gmail dot com @ 2013-08-09 12:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58109

            Bug ID: 58109
           Summary: alignas() fails to compile with constant expression
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janezz55 at gmail dot com

Created attachment 30626
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30626&action=edit
file demonstrating bug

The following example compiles without issue with clang++ 3.3:

#include <cassert>

#include <string>

#include <type_traits>

#include <typeinfo>

#include <utility>

namespace detail
{

template <typename A, typename ...B>
struct max_align
  : std::integral_constant<std::size_t,
      (alignof(A) > max_align<B...>{}) ? alignof(A) : max_align<B...>{}>
{
};

template <typename A, typename B>
struct max_align<A, B>
  : std::integral_constant<std::size_t,
      (alignof(A) > alignof(B)) ? alignof(A) : alignof(B)>
{
};

template <typename A>
struct max_align<A>
  : std::integral_constant<std::size_t, alignof(A)>
{
};

};

template <typename ...T>
struct test
{
  alignas(::detail::max_align<T...>::value) char store_[10];
};

int main()
{
  test<std::string, int> a;

  return 0;
}

But even with g++-4.9, it fails with:

t.cpp:39:59: error: requested alignment is not an integer constant
   alignas(::detail::max_align<T...>::value) char store_[10];


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

end of thread, other threads:[~2021-09-20 22:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09 12:37 [Bug c++/58109] New: alignas() fails to compile with constant expression janezz55 at gmail dot com
2013-08-09 12:59 ` [Bug c++/58109] " paolo.carlini at oracle dot com
2013-08-09 13:02 ` janezz55 at gmail dot com
2013-08-09 13:06 ` paolo.carlini at oracle dot com
2013-11-05 22:16 ` paolo.carlini at oracle dot com
2021-09-20 22:01 ` 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).