]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Distinguish alignof and __alignof__ in cp_tree_equal [PR97273]
authorPatrick Palka <ppalka@redhat.com>
Thu, 8 Oct 2020 23:31:57 +0000 (19:31 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 8 Oct 2020 23:31:57 +0000 (19:31 -0400)
commitaeb69dda51e93379fce10fb03ec57650fbf73f31
tree918fbdfbdd944fc2a3bff33ef7c65725193f8f0e
parente4c9aac98611f63847ef6c57916808d9a2d7abcb
c++: Distinguish alignof and __alignof__ in cp_tree_equal [PR97273]

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
table (which uses cp_tree_equal as its 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.

gcc/cp/ChangeLog:

PR c++/88115
PR libstdc++/97273
* tree.c (cp_tree_equal) <case ALIGNOF_EXPR>: Return false if
ALIGNOF_EXPR_STD_P differ.

gcc/testsuite/ChangeLog:

PR c++/88115
PR libstdc++/97273
* g++.dg/template/alignof3.C: New test.

(cherry picked from commit 592fe221735bdaa375b1834dd49ce125d0b600d8)
gcc/cp/tree.c
gcc/testsuite/g++.dg/template/alignof3.C [new file with mode: 0644]