Test case (https://godbolt.org/z/34KB20): struct Z { int y; }; template <class T> constexpr Z f(const T *data) { Z z; __builtin_memcpy(&z, data, sizeof(z)); return z; } constexpr Z g(const char *data) { return f(data); } This prints: <source>: In instantiation of 'constexpr Z f(const T*) [with T = char]': <source>:12:48: required from here <source>:1:8: note: 'struct Z' has no user-provided default constructor <source>:2:7: note: and the implicitly-defined constructor does not initialize 'int Z::y' If f is not a template, `Z z;` is an error and the notes explain the error. But when f is a template the error is suppressed (seems correct). However the notes that explain the error are still shown. Whether the notes are shown should use the same condition as the error.
Up to GCC 7.2 there's an error for the example, with notes. The error was fixed by r251429 for PR 80935 (and with r252943 on gcc-7-branch) so from 7.3 the error isn't given, but the notes remain.
Patch posted to https://gcc.gnu.org/ml/gcc-patches/2019-04/msg01009.html
Author: redi Date: Fri Apr 26 16:33:02 2019 New Revision: 270610 URL: https://gcc.gnu.org/viewcvs?rev=270610&root=gcc&view=rev Log: PR c++/90243 - orphaned note in uninstantiated constexpr function gcc/cp: PR c++/90243 - orphaned note in uninstantiated constexpr function * decl.c (check_for_uninitialized_const_var): Suppress notes if no error was shown. gcc/testsuite: PR c++/90243 * g++.dg/diagnostic/pr90243.C: New test. Added: trunk/gcc/testsuite/g++.dg/diagnostic/pr90243.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk.
*** Bug 91070 has been marked as a duplicate of this bug. ***
This is still present on gcc-8-branch and gcc-9-branch.
*** Bug 92519 has been marked as a duplicate of this bug. ***
*** Bug 93311 has been marked as a duplicate of this bug. ***