public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110930] New: Fix-it hints suggest wrong header for names in the global namespace
@ 2023-08-07 10:14 redi at gcc dot gnu.org
  2023-08-07 12:09 ` [Bug c++/110930] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-08-07 10:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110930
           Summary: Fix-it hints suggest wrong header for names in the
                    global namespace
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Given:

uint32_t i = 0;

We say:

dcl.cc:1:1: error: 'uint32_t' does not name a type
    1 | uint32_t i = 0;
      | ^~~~~~~~
dcl.cc:1:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | uint32_t i = 0;


But this is wrong. uint32_t is declared in <stdint.h>, std::uint32_t is
declared in <cstdint>.

We should not be encouraging reliance on the non-portable property that some
implementations of <cstdint> leak the name into the global namespace as well as
namespace std.

This is the case for every name in the C++ stdlib that comes from the C stdlib.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-07 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 10:14 [Bug c++/110930] New: Fix-it hints suggest wrong header for names in the global namespace redi at gcc dot gnu.org
2023-08-07 12:09 ` [Bug c++/110930] " rguenth at gcc dot gnu.org
2023-08-07 12:28 ` redi at gcc dot gnu.org
2023-08-07 15:33 ` pinskia at gcc dot gnu.org
2023-08-07 15:35 ` pinskia at gcc dot gnu.org
2023-08-07 15:36 ` redi at gcc dot gnu.org

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).