In the sizeof / sizeof operator expression handling we're missing
a dependence check for the second operand.
PR c++/114888
gcc/cp/ChangeLog:
* typeck.cc (cp_build_binary_op) <case *_DIV_*>: Add missing
dependence check for the second sizeof operand.
gcc/testsuite/ChangeLog:
* g++.dg/template/sizeof19.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
if (!TYPE_P (type1))
type1 = TREE_TYPE (type1);
if (type0
+ && type1
&& INDIRECT_TYPE_P (type0)
&& same_type_p (TREE_TYPE (type0), type1))
{
--- /dev/null
+// PR c++/114888
+
+template<class>
+struct A {
+ struct B {} *b;
+ static const int c = sizeof (b) / sizeof (b[0]);
+};
+const int d = A<int>::c;