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

* [Bug c++/110930] Fix-it hints suggest wrong header for names in the global namespace
  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 ` rguenth at gcc dot gnu.org
  2023-08-07 12:28 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-07 12:09 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-08-07

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Maybe still OK for code using 'using std'?  I wonder if we can
check for that somehow.

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

* [Bug c++/110930] Fix-it hints suggest wrong header for names in the global namespace
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-08-07 12:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yeah, that using-directive complicates things.

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

* [Bug c++/110930] Fix-it hints suggest wrong header for names in the global namespace
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I had noticed this too.

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

* [Bug c++/110930] Fix-it hints suggest wrong header for names in the global namespace
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I see Jonathan had mentioned this issue in bug 85690 comment #1 too.

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

* [Bug c++/110930] Fix-it hints suggest wrong header for names in the global namespace
  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
                   ` (3 preceding siblings ...)
  2023-08-07 15:35 ` pinskia at gcc dot gnu.org
@ 2023-08-07 15:36 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-08-07 15:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Ah yes, this is a dup of the second half of that one, but maybe worth keeping
it separate.

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