public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rs2740 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/110164] New: Improve diagnostic for incomplete standard library types due to missing include
Date: Wed, 07 Jun 2023 21:49:36 +0000	[thread overview]
Message-ID: <bug-110164-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110164
           Summary: Improve diagnostic for incomplete standard library
                    types due to missing include
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

If I forget to include a header before using a sufficiently well-known standard
library type, GCC helpfully reminds me of the header:

$ echo 'std::array<int, 10> x;' | g++ -x c++ -

<stdin>:1:6: error: ‘array’ in namespace ‘std’ does not name a template type
<stdin>:1:1: note: ‘std::array’ is defined in header ‘<array>’; did you forget
to ‘#include <array>’?

But if I happen to have a different standard library header included that
happens to bring in a forward declaration of the type, the error message is
less helpful:

$ echo -e '#include <map>\nstd::array<int, 10> x;' | g++ -x c++ -

<stdin>:2:21: error: aggregate ‘std::array<int, 10> x’ has incomplete type and
cannot be defined

It would be nice if the latter case also has a hint about the potential missing
include.

             reply	other threads:[~2023-06-07 21:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 21:49 rs2740 at gmail dot com [this message]
2023-06-07 21:56 ` [Bug c++/110164] " pinskia at gcc dot gnu.org
2023-06-13 22:51 ` dmalcolm at gcc dot gnu.org
2023-06-21 20:41 ` dmalcolm at gcc dot gnu.org
2023-06-21 20:50 ` pinskia at gcc dot gnu.org
2023-06-23 21:57 ` cvs-commit at gcc dot gnu.org
2023-06-23 22:03 ` dmalcolm at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-110164-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).