On Fri, 9 Oct 2020, Jason Merrill wrote: > On 10/9/20 4:48 AM, Jakub Jelinek wrote: > > On Tue, Oct 06, 2020 at 03:40:52PM -0400, Jason Merrill via Gcc-patches > > wrote: > > > On 10/4/20 11:28 PM, Patrick Palka wrote: > > > > cp_tree_equal currently considers alignof the same as __alignof__, but > > > > these operators are semantically different ever since r8-7957. In the > > > > testcase below, this causes the second static_assert to fail on targets > > > > where alignof(double) != __alignof__(double) because the specialization > > > > cache (which uses cp_tree_equal as the equality predicate) conflates the > > > > two dependent specializations integral_constant<__alignof__(T)> and > > > > integral_constant<alignof(T)>. > > > > > > > > This patch makes cp_tree_equal distinguish between these two operators > > > > by inspecting the ALIGNOF_EXPR_STD_P flag. > > > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu, and also verified > > > > that we now correctly compile the PR97273 testcase, does this look OK > > > > for trunk and the release branches? > > > > > > OK. > > > > Shouldn't we then mangle alignof and __alignof__ differently though? > > Good point. Then I guess __alignof__ should be mangled as v111__alignof__
While working on this mangling change, I noticed that the non-standard extension alignof(expr) returns the preferred alignment, so it behaves like __alignof__(type) instead of alignof(type). Do we want to keep it that way, or should we make it behave like alignof(type) and return the ABI alignment instead (and therefore set ALIGNOF_EXPR_STD_P on it and mangle it as "az" instead of "v111__alignof__z" etc)? FWIW, on Clang alignof(expr) returns the ABI alignment. > > Jason > >