public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janezz55 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58109] New: alignas() fails to compile with constant expression
Date: Fri, 09 Aug 2013 12:37:00 -0000	[thread overview]
Message-ID: <bug-58109-4@http.gcc.gnu.org/bugzilla/> (raw)

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];


             reply	other threads:[~2013-08-09 12:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 12:37 janezz55 at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58109-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).