From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5E970385842C; Wed, 7 Feb 2024 22:23:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E970385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707344629; bh=qfuuvdE6mlqFkMjYtjkvrO6yVBToCdZ+dR2C2/RI6vs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=c+8A1zYo49dbZaY6jhqB1e0saRBwxkXy9pW3biheIaEkxL/IxImGAnKTJS3YqSJLl jaxiaz9GW/dVxD3JIEgdi081+bKUV6DegJDOFncKapdxsiS1YKSjDgTi8n5EjB0Jix sFI3TCVlNRTLVu2/xqjphJKusOxja/+Qe+L6US04= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113074] std::to_address should be SFINAE safe Date: Wed, 07 Feb 2024 22:23:48 +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: 13.2.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=3D113074 --- Comment #13 from Jonathan Wakely --- It looks like libc++ did it for this reason: [libc++] Fix a hard error in `contiguous_iterator`. Evaluating `contiguous_iterator` on an iterator that satisfies all the constraints except the `to_address` constraint and doesn't have `operator->` defined results in a hard error. This is because instantiating `to_address` ends up instantiating templates dependent on the given type which might lead to a hard error even in a SFINAE context. Differential Revision: https://reviews.llvm.org/D130835 As I said in comment 7, LWG considered this case and it was pointed out that the problem described can only occur if a type defines iterator_concept =3D contiguous_iterator; but then fails to actually provide the operations need= ed for a contiguous iterator (i.e. either a pointer_traits specialization with to_address or a sane operator->()). A SFINAE-friendly std::to_address as implemented in libc++ means that such = an iterator will fail to satisfy std::contiguous_iterator and will silently degrade to satosfying std::random_access_iterator only. It's not at all cle= ar to me that silently degrading such an iterator (which very explicitly claim= s to be a contiguous iterator by defining iterator_concept to say so) would be an improvement. I'd rather get an error telling me the thing I thought was a contiguous iterator was not actually.=