From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 772F93857820; Fri, 11 Mar 2022 15:20:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 772F93857820 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/104883] New: should define all std::errc enumerators Date: Fri, 11 Mar 2022 15:20:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2022 15:20:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104883 Bug ID: 104883 Summary: should define all std::errc enumerators Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- Currently we only define std::errc enumerators when the OS defines the corresponding errno macro: #ifdef EOVERFLOW value_too_large =3D EOVERFLOW, #endif Which causes errors when we rely on that being present, e.g. for AVR: /home/jwakely/src/gcc/build-avr/avr/libstdc++-v3/include/charconv: In funct= ion =E2=80=98std::to_chars_result std::__detail::__to_chars(char*, char*, _Tp, = int)=E2=80=99: /home/jwakely/src/gcc/build-avr/avr/libstdc++-v3/include/charconv:132:28: error: =E2=80=98value_too_large=E2=80=99 is not a member of =E2=80=98std::e= rrc=E2=80=99; did you mean =E2=80=98file_too_large=E2=80=99? 132 | __res.ec =3D errc::value_too_large; | ^~~~~~~~~~~~~~~ | file_too_large And src/filesystem/ops-common.h does this to workaround the fact that std::errc::not_supported isn't always defined: inline error_code __unsupported() noexcept { #if defined ENOTSUP return std::make_error_code(std::errc::not_supported); #elif defined EOPNOTSUPP // This is supposed to be for socket operations return std::make_error_code(std::errc::operation_not_supported); #else return std::make_error_code(std::errc::invalid_argument); #endif } We should consider defining all the enumerators unconditionally, picking va= lues outside the range used by the OS for constants, e.g. #ifdef EOVERFLOW value_too_large =3D EOVERFLOW, #else value_too_large =3D 1001, #endif The tricky part is picking a value range that doesn't clash with the OS. For the OS-specific headers such as config/os/mingw32-w64/error_constants.h we = can just inspect and make an educated choice. For config/os/generic/error_constants.h maybe we want to do something in config= ure or with the preprocessor to find the largest value among all the errno macr= os that *are* defined, and add 100. Or just take a gamble and assume the OS us= es small numbers and we can start from 1000, or 32000, or something.=