diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-04-29 21:14:18 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-04-29 21:14:18 -0400 |
commit | 3900e944b0ac9db77380c5bb8635977dfd3b0691 (patch) | |
tree | a3e4f629c412d45b61f82fd78d47746bc5302f29 /gcc | |
parent | 42d2e2f57e943c0f79940729d1ef1945388499de (diff) | |
download | gcc-3900e944b0ac9db77380c5bb8635977dfd3b0691.zip gcc-3900e944b0ac9db77380c5bb8635977dfd3b0691.tar.gz gcc-3900e944b0ac9db77380c5bb8635977dfd3b0691.tar.bz2 |
c++: ICE with templated sizeof(E1) / sizeof(E2) [PR114888]
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/typeck.cc | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/sizeof19.C | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index e5a52dc..a25f862 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -5501,6 +5501,7 @@ cp_build_binary_op (const op_location_t &location, if (!TYPE_P (type1)) type1 = TREE_TYPE (type1); if (type0 + && type1 && INDIRECT_TYPE_P (type0) && same_type_p (TREE_TYPE (type0), type1)) { diff --git a/gcc/testsuite/g++.dg/template/sizeof19.C b/gcc/testsuite/g++.dg/template/sizeof19.C new file mode 100644 index 0000000..a146799 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof19.C @@ -0,0 +1,8 @@ +// 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; |