Repository navigation
Spurious "did not produce a valid constant expression" when a consteval function returns the address of a function that calls it
#168
stevensudit-corvid
started this conversation in
Issue Triage - Compilation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
The front end rejects a
constevalmember function template that returns the address of another member function template whose body calls it back. It reports theconstevalfunction as "not completely defined yet".gcc and clang accept the code. I ran into it in a type-erased callable whose
constevaldispatch-table builder takes the address of a thunk that installs the same table.Reproducing Source Code
Command-line Options
cpfe --c++23 repro.cpp
Type of Issue
[Front End] This code SHOULD compile with these options.
Additional Details
The diagnostic, at 158320e (version 7.0):
The trace shows
live<1>being instantiated whilemake<1>is still being instantiated. Evaluatingmake<1>()needs only the address oflive<1>, not its body, so the body can be instantiated aftermake<1>is complete, and then the call inside it evaluates.--c++20and--c++26give the same error, and so do the GNU, Clang and Microsoft modes.Any one of these changes makes it compile:
livedoes not callmake, so there is no cycle.liveis defined outside the class.getis defined outside the class.makeisconstexprinstead ofconsteval.It still fails when
getis a member of a different class, and whentis a class template whose members are not themselves templates.A possibly related symptom, in the default mode only: without
get, callingt::make<1>()directly from non-template code, for examplebool (*p)() = t::make<1>();, gives the same error. In the GNU and Clang modes that form compiles.nvcc 13.3, which embeds EDG 6.8, rejects the six-line file with the same message, so this is not new in 7.0.
Reproducing (Standard) Configuration(s)
linux-gcc-release
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions