[Bug c++/93093] __builtin_source_location reports values for default arguments not aligned with the Standard

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 31 15:41:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93093

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
What this boils down to is e.g. whether
consteval int foo (int i) { if (i) throw 1; return 0; }
void bar (int x = foo (0));
void baz (int x = foo (1));
void qux () { bar (0); bar (); baz (0); }
needs to be rejected (it is rejected by g++) or not, if it is invalid, no
diagnostics required, or if it would be invalid only if there would be a baz
(); call somewhere.
If the above testcase is invalid, and default arguments to non-immediate
functions need to be evaluated if they contain calls to immediate functions,
then I don't see how your #c0 testcase can expect what it expects, because
source_location::current() will be evaluated not when you expect it to and by
the time something else invokes the constructor or function, the default
argument will already have a constant value.


More information about the Gcc-bugs mailing list