]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix null deref in maybe_diagnose_standard_trait [PR121859]
authorNathaniel Shead <nathanieloshead@gmail.com>
Tue, 9 Sep 2025 23:59:23 +0000 (09:59 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Wed, 10 Sep 2025 12:22:33 +0000 (22:22 +1000)
commit7fc9265ee5b20c4191b8fcad47234148c72f7b03
tree82578eaa1a9d3c1c68d6def7284c2dcee5107b42
parent008ad1c6bad820cacdfd6a6d907330ed2577a696
c++: Fix null deref in maybe_diagnose_standard_trait [PR121859]

A static member template doesn't always have a DECL_INITIAL, as in the
below testcase, and so checking its TREE_CODE performs a null-pointer
dereference.  I don't think we need to specially detect this case as
traits we care about are unlikely to be members, so this just adds the
missing null check.

PR c++/121859

gcc/cp/ChangeLog:

* constraint.cc (maybe_diagnose_standard_trait): Check if expr
is non-null.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-traits5.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/constraint.cc
gcc/testsuite/g++.dg/cpp2a/concepts-traits5.C [new file with mode: 0644]