From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 718AE3858D3C; Mon, 28 Nov 2022 11:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 718AE3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669633695; bh=77u22mVrNE/M0vlOqrFnapDLMm2N+QzBvs6wIheWmNM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kCbOdn5D9a2JnnwoDGAQx58hyT3IxXsFKwC8tZupc53+vLpj8/vfapjoX0wFUQciV cOfGphMAAQO61tqbxKbyWrApiJWpkEBu7DJqAEz47py5QVOKrFi4cCXChGcW1DG04A xSfbAI3gu4Y3fphuVt/TAlQp9xlfSzHPMF8lyvs0= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107894] [feature request] _GLIBCXX_ASSERTIONS for std::optional Date: Mon, 28 Nov 2022 11:08:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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_status resolution Message-ID: In-Reply-To: References: 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=3D107894 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #1 from Jonathan Wakely --- (In reply to tim blechmann from comment #0) > `_GLIBCXX_ASSERTIONS` does not enable any API validation for std::optiona= l. I don't know why people keep claiming this, but it's nonsense. tmp$ cat opt.cc #include int main() { std::optional o; return *o.operator->(); } tmp$ g++ -D_GLIBCXX_ASSERTIONS opt.cc tmp$ ./a.out /usr/include/c++/12/optional:477: constexpr _Tp& std::_Optional_base_impl<_= Tp, _Dp>::_M_get() [with _Tp =3D int; _Dp =3D std::_Optional_base]: Assertion 'this->_M_is_engaged()' failed. Aborted (core dumped) > it would be great if libstdc++ could perform the same validation It already does, please try it instead of just skimming the code. *** This bug has been marked as a duplicate of bug 102712 ***=