From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4012C3858D38; Wed, 22 May 2024 19:56:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4012C3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716407789; bh=4OU0I5166ptrNcZgcKqM6Dw3pt5xBaMwL7Gane5WQEs=; h=From:To:Subject:Date:From; b=ChM3RqgoeP+idTnIXoS83q0RJEx0o9x8phCLH7dRU+c26MWDtBhpv5YS/2xdF5lzu 3QHzvmyoC+7I0yjagoovIx989fjxGGPWyvfuTcnH9CbmWfHNPffjRYYIYyAOvq06uq 3Un6v/WCMfoOj7Z6iu5dCJL49PMy3PiKqZ4+KX1k= From: "luigighiron at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luigighiron at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115196 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 int main(){ std::to_address((void*)0); } std::to_address was introduced in C++20 so when using the default compilati= on settings, i.e. C++17 this code is invalid. This is the generated error mess= age from testing on godbolt with GCC 14.1.0: : In function 'int main()': :3:10: error: 'to_address' is not a member of 'std' 3 | std::to_address((void*)0); | ^~~~~~~~~~ :2:1: note: 'std::to_address' is defined in header ''; this= is probably fixable by adding '#include ' 1 | #include +++ |+#include 2 | int main(){ This note doesn't seem to be very helpful, it mentions adding an extra '#include' 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.=