public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "luigighiron at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/115196] New: Bad error message when using library functions from versions before they were introduced Date: Wed, 22 May 2024 19:56:28 +0000 [thread overview] Message-ID: <bug-115196-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115196 Bug ID: 115196 Summary: Bad error message when using library functions from versions before they were introduced Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- GCC generates some error messages when attempting to use library functions without including the appropriate header, indicating that the appropriate header should be included. This seems to act incorrectly when attempting to use a library function from a version before the function was introduced, for example: #include<memory> int main(){ std::to_address((void*)0); } std::to_address was introduced in C++20 so when using the default compilation settings, i.e. C++17 this code is invalid. This is the generated error message from testing on godbolt with GCC 14.1.0: <source>: In function 'int main()': <source>:3:10: error: 'to_address' is not a member of 'std' 3 | std::to_address((void*)0); | ^~~~~~~~~~ <source>:2:1: note: 'std::to_address' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>' 1 | #include<memory> +++ |+#include <memory> 2 | int main(){ This note doesn't seem to be very helpful, it mentions adding an extra '#include<memory>' when one is already present. A better error message here would be to omit the note, or to make it mention changing the selected C++ standard version.
next reply other threads:[~2024-05-22 19:56 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-22 19:56 luigighiron at gmail dot com [this message] 2024-05-22 20:00 ` [Bug c++/115196] " pinskia at gcc dot gnu.org 2024-05-22 20:01 ` sjames at gcc dot gnu.org 2024-05-22 20:01 ` redi at gcc dot gnu.org 2024-05-22 20:13 ` redi at gcc dot gnu.org 2024-05-22 20:28 ` luigighiron at gmail dot com
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-115196-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: linkBe 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).