* Reason for missing notes for incomplete-type errors in standard headers
@ 2022-08-05 16:38 Julian Lenz
2022-08-05 16:55 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Julian Lenz @ 2022-08-05 16:38 UTC (permalink / raw)
To: gcc
Hi everybody,
TL;DR:
What is the reason that `error: '<some class>' has incomplete type` does
not give a note about where the forward declaration happened for
standard library classes?
Full:
Recently, I forgot to include <array> but had <tuple> included. Due to
this recent commit for gcc12
https://github.com/gcc-mirror/gcc/commit/261d5a4a459bd49942e53bc83334ccc7154a09d5
the `error: 'std::array<int,N>' has incomplete type` felt like a weird
regression because all other major gcc versions as well as clang
compiled just fine. After many hours of debugging, I finally realised
that it was just a missing header and now the error message actually
makes sense.
But when I experimented with this, I found that gcc does give you
another `<filename>:<line number>:<column number>: note: declaration of
'class SomeClass<int>'` with line number and everything. Now, I wonder
why gcc doesn't do that for standard headers (at least not in my
particular case). Is there a compelling argument for that? It feels like
it must be intentional. If not, I would suggest adding that because I'm
pretty sure it would have spared me a couple of hours just by realising
quickly that it takes `std::array` from the wrong header.
Thank you in advance and keep up the great work!
Julian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Reason for missing notes for incomplete-type errors in standard headers
2022-08-05 16:38 Reason for missing notes for incomplete-type errors in standard headers Julian Lenz
@ 2022-08-05 16:55 ` Jonathan Wakely
2022-08-05 20:27 ` Julian Lenz
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2022-08-05 16:55 UTC (permalink / raw)
To: Julian Lenz; +Cc: gcc
On Fri, 5 Aug 2022 at 17:39, Julian Lenz via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi everybody,
>
> TL;DR:
>
> What is the reason that `error: '<some class>' has incomplete type` does
> not give a note about where the forward declaration happened for
> standard library classes?
Probably because the declaration happens in a system header.
Does -Wsystem-headers change it?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Reason for missing notes for incomplete-type errors in standard headers
2022-08-05 16:55 ` Jonathan Wakely
@ 2022-08-05 20:27 ` Julian Lenz
0 siblings, 0 replies; 3+ messages in thread
From: Julian Lenz @ 2022-08-05 20:27 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc
Hi Jonathan,
Thanks for the quick answer. No, it doesn't for the simplest possible case:
#include <tuple>
int main() { std::array<int,1> arr; };
But admittedly that would have been a surprise to me as I usually
compile with -Wall -Wextra -Werror.
But I tried to replace `<array>` with `<tuple>` in yet another code
(tiny but real-life, so not as trivial as above) with two appearances of
`std::array` and there, one does yield the note.
I boiled it down to the following: The typename seems to not yield the
note but the constructor does notify, i.e. in
1 std::array<int,1> f() {
2 return std::array<int,1>{{1}};
3 }
Line 1 and 2 raise an error but only Line 2 comes with a note.
Best,
Julian
On 05/08/2022 17:55, Jonathan Wakely wrote:
> On Fri, 5 Aug 2022 at 17:39, Julian Lenz via Gcc <gcc@gcc.gnu.org> wrote:
>> Hi everybody,
>>
>> TL;DR:
>>
>> What is the reason that `error: '<some class>' has incomplete type` does
>> not give a note about where the forward declaration happened for
>> standard library classes?
> Probably because the declaration happens in a system header.
>
> Does -Wsystem-headers change it?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-05 20:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 16:38 Reason for missing notes for incomplete-type errors in standard headers Julian Lenz
2022-08-05 16:55 ` Jonathan Wakely
2022-08-05 20:27 ` Julian Lenz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).