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
* [Bug c++/58109] alignas() fails to compile with constant expression
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 ` paolo.carlini at oracle dot com
2013-08-09 13:02 ` janezz55 at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-09 12:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58109
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-08-09
CC| |dodji at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Let's simplify this:
template <typename T>
struct max_align
{
static const int value = alignof(T);
};
template <typename T>
struct test
{
alignas(max_align<T>::value) char store_;
};
template class test<double>;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/58109] alignas() fails to compile with constant expression
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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janezz55 at gmail dot com @ 2013-08-09 13:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58109
--- Comment #2 from Janez Zemva <janezz55 at gmail dot com> ---
Please don't neglect std::integral_constant, as it is has a constexpr
conversion operator and so one can use its "instance" as a template parameter.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/58109] alignas() fails to compile with constant expression
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
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-09 13:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58109
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I don't think it's necessary to demonstrate the bug. Whoever will fix it, for
sure will double check with the original testcase too.
Adding Jason too in CC, this could be a re-opened c++/56859.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/58109] alignas() fails to compile with constant expression
2013-08-09 12:37 [Bug c++/58109] New: alignas() fails to compile with constant expression janezz55 at gmail dot com
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-05 22:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58109
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |redi at gcc dot gnu.org
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 59013 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/58109] alignas() fails to compile with constant expression
2013-08-09 12:37 [Bug c++/58109] New: alignas() fails to compile with constant expression janezz55 at gmail dot com
` (3 preceding siblings ...)
2013-11-05 22:16 ` paolo.carlini at oracle dot com
@ 2021-09-20 22:01 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-20 22:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58109
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |6.0
^ 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).