Created attachment 38345 [details] testcase Invoked as: nathan@morden:28>./cc1plus -fpreprocessed cexpr-error.ii we get: constexpr int fn6(const int&, int) constexpr int fn7(const int*, int) cexpr-error.ii: At global scope: cexpr-error.ii:17:24: in constexpr expansion of 'fn7(0u, 0)' cexpr-error.ii:14:14: in constexpr expansion of 'fn6((* a), b)' cexpr-error.ii:7:7: error: 'a' is not a constant expression b = a; ^ cexpr-error.ii:18:24: in constexpr expansion of 'fn7(0u, 8)' cexpr-error.ii:14:14: in constexpr expansion of 'fn6((* a), b)' cexpr-error.ii:6:13: in constexpr expansion of 'fn6(a, 0)' cexpr-error.ii:18:43: error: 'a' is not a constant expression constexpr int n4 = fn7 ((const int *) 0, 8); The first error is correctly located at tha 'b = a;' location. The second instance is not, and shows the original call site. inside constexpr.c the first error is from an evaluation of the original function body. the second is from a cloned copy via the recursive call. Something about cloning is throwing off the error location.
GCC 7-13 does: ``` <source>:17:24: in constexpr expansion of 'fn7(0, 0)' <source>:17:43: error: dereferencing a null pointer constexpr int n3 = fn7 ((const int *) 0, 0); ^ <source>:18:24: in constexpr expansion of 'fn7(0, 8)' <source>:18:43: error: dereferencing a null pointer constexpr int n4 = fn7 ((const int *) 0, 8); ^ ``` While the trunk gives: ``` <source>:17:24: in 'constexpr' expansion of 'fn7(0, 0)' <source>:14:14: error: dereferencing a null pointer 14 | return fn6 (*a, b); | ~~~~^~~~~~~ <source>:18:24: in 'constexpr' expansion of 'fn7(0, 8)' <source>:14:14: error: dereferencing a null pointer ``` Which seems like the correct location now.
Changed in r14-2771 commit 5ebe5bcf8b6b6a0de16737b717e8bd06e4950a14 Author: Nathaniel Shead <nathanieloshead@gmail.com> Date: Sun Jul 23 01:13:43 2023 +1000 c++: Improve location information in constant evaluation So I guess fixed.