From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F85D3858C5F; Mon, 30 Oct 2023 14:49:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F85D3858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698677398; bh=Kzjv4fdLWJSp668gKlTyrjW5JTYundKOZ0HkoPN7E9E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ClpSOkxBO2H4FahFR1Ma3nBGJeAjTkG8ax2GJYuzyNXkYa9gngYX70i2bJkxoaXEI 8BnKpntx9m2QFkyOT93mBIxdPPW3YDBW+88Gi0YKm30B7x9eXfHlv8yqAA/2aZ3Uoh lKwg/z4u9OrPrzxbnjDdezFuALwGSxd+H2JnvFNI= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112296] __builtin_constant_p doesn't propagate through member functions Date: Mon, 30 Oct 2023 14:49:58 +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: 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: 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=3D112296 --- Comment #3 from Jonathan Wakely --- (In reply to Barry Revzin from comment #0) > inline int direct(Span span) { > return __builtin_constant_p(span.size()); > } >=20 > inline int indirect(Span span) { > size_t s =3D span.size(); > return __builtin_constant_p(s); > } If the problem is that bcp is limited by inlining, you'd think that the fir= st one would be more likely to work. It does less. Clearly inlining can see through the member function, because in 'indirect'= it can propagate its return value through 's' and to the bcp call. But in 'direct' the return value is somehow not constant when used directly= . It is only constant if propagated through a local variable. That seems like an unnecessary limitation.=