From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 566823858407; Mon, 7 Aug 2023 07:41:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 566823858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691394104; bh=07mr+Q4qq4kIGYyefpts7yqIK9m6NGHUziPX9/oHLcY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qKvMrxU26aE+OQLABQdyj2nD2r5baI7pC9E5CDqKq0upQjcOxY53md/jpE//hE4p2 uXy9azbt/3DJwmUDh+fxaQ/rHoqWNoPSjQsFuN4Hj9TjOMfuhkZleveEIM5Ld7wF2W WsFQ3C3Me04R12ux6gIOBd6pWVPkjG0R5B6QmSfc= From: "fchelnokov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110619] Dangling pointer returned from constexpr function converts in nullptr Date: Mon, 07 Aug 2023 07:41:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: accepts-invalid, diagnostic, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: fchelnokov 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: 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=3D110619 --- Comment #8 from Fedor Chelnokov --- Please note that GCC 13 also accepts invalid program (because dangling poin= ters were converted in nullptr): constexpr auto f(int a) { return &a; } constexpr auto g(int b) { return &b; } static_assert(f(1) <=3D g(2)); This program must be rejected because of relational comparison of unrelated pointers as Clang and MSVC do, online demo: https://gcc.godbolt.org/z/q5z3G= vehe And your patch fixes it as well, thanks.=