The following snippet #include <algorithm> struct One {}; struct Two {}; struct Foo { alignas(std::max(alignof(One), alignof(Two))) char value; }; compiles fine in GCC 9.3, but in GCC 8.4 fails with test.cpp:5:65: error: requested alignment is not an integer constant struct Foo { alignas(std::max(alignof(One), alignof(Two))) char value; }; ^~~~~
. *** This bug has been marked as a duplicate of bug 90736 ***
Hmm, although this was fixed for gcc 9.2 by the patch for PR 90736 it seems to be a different root cause. This compiled with GCC 5 but not 6, 7 or 8: template<typename T> constexpr const T& max(const T& a, const T& b) { return a < b ? b : a; } struct One {}; struct Two {}; struct Foo { alignas(max(alignof(One), alignof(Two))) char value; }; This regressed with r230365, "Merge C++ delayed folding branch." Marek, looks like backporting r272219 would fix this.
I'm going to backport the fix to 8 if it passes the usual testing.
Done in r8-10235-gf6965321b1c00bfb2b9c8407df56bcf38f096088.
(In reply to Marek Polacek from comment #3) > I'm going to backport the fix to 8 if it passes the usual testing. Hi Marek, could you also test the inlined code. Defining some const and then using it alignas worked previously, the problem comes from doing all of it in alignas().
(In reply to David Seifert from comment #5) > (In reply to Marek Polacek from comment #3) > > I'm going to backport the fix to 8 if it passes the usual testing. > > Hi Marek, > could you also test the inlined code. Defining some const and then using it > alignas worked previously, the problem comes from doing all of it in > alignas(). Both the original testcase in this PR and the test in Comment 2 now compile even with GCC 8.