https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88115
Bug ID: 88115 Summary: Incorrect result from alignof in templates, if also using __alignof__. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: foom at fuhm dot net Target Milestone: --- On both GCC 8.2 and "trunk" on godbolt (https://godbolt.org/z/ykszUZ) given the following program, compiled for x86 -m32, the final GCCAlignOf static assert unexpectedly fails. However, if you comment out the three StdAlignOf lines, the assert starts passing. Or, if you swap the order such that GCCAlignOf comes first, then it will pass, and the StdAlignOf assert fails, instead. It looks like some caching inside GCC is still treating alignof and __alignof as the same thing, even though they now (since the fix for PR69560) are supposed to have differing behavior. Possibly this is due to both alignof and __alignof mangling to the same character? === static_assert(alignof(double) == 4, ""); static_assert(__alignof__(double) == 8, ""); template<typename _Tp, _Tp __v> struct integral_constant { static constexpr _Tp value = __v; }; template <class T> using StdAlignOf = integral_constant<unsigned long, alignof(T)>; static_assert(StdAlignOf<double>::value == 4, ""); template <class T> using GCCAlignOf = integral_constant<unsigned long, __alignof__(T)>; static_assert(GCCAlignOf<double>::value == 8, ""); ===