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.

Reply via email to