]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Don't mix timevar_start and auto_cond_timevar for TV_NAME_LOOKUP [PR116681]
authorSimon Martin <simon@nasilyan.com>
Mon, 24 Mar 2025 07:15:54 +0000 (08:15 +0100)
committerSimon Martin <simartin@gcc.gnu.org>
Mon, 24 Mar 2025 07:15:54 +0000 (08:15 +0100)
commit8bac22817192349cad15c88e01a73798e2a783ad
tree82346fb6742bc9ae8d796c1d6620e6aacddb8f72
parent2ba78236539c14e1aa58444926efb6d04d42d9f6
c++: Don't mix timevar_start and auto_cond_timevar for TV_NAME_LOOKUP [PR116681]

We currently ICE upon the following testcase when using -ftime-report

=== cut here ===
template < int> using __conditional_t = int;
template < typename _Iter >
concept random_access_iterator = requires { new _Iter; };
template < typename _Iterator >
struct reverse_iterator {
  using iterator_concept =
    __conditional_t< random_access_iterator< _Iterator>>;
};
void RemoveBottom() {
  int iter;
  for (reverse_iterator< int > iter;;)
      ;
}
=== cut here ===

The problem is that qualified_namespace_lookup does a plain start() of
the TV_NAME_LOOKUP timer (that asserts that the timer is not already
started). However this timer has already been cond_start()'d in the call
stack - by pushdecl - so the assert fails.

This patch simply ensures that we always conditionally start this timer
(which is done in all other places that use it).

PR c++/116681

gcc/cp/ChangeLog:

* name-lookup.cc (qualified_namespace_lookup): Use an
auto_cond_timer instead of using timevar_start and timevar_stop.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 005f7176e0f457a1e1a7398ddcb4a4972da28c62)
gcc/cp/name-lookup.cc
gcc/testsuite/g++.dg/cpp2a/concepts-pr116681.C [new file with mode: 0644]