From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82910 invoked by alias); 13 Mar 2017 11:33:07 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 82886 invoked by uid 89); 13 Mar 2017 11:33:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=U*jwakely.gcc, H*i:sk:CAH6eHd, H*f:sk:g7A@mai, jwakelygccgmailcom X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Mar 2017 11:33:04 +0000 Received: by mail-wm0-f52.google.com with SMTP id n11so37463749wma.0 for ; Mon, 13 Mar 2017 04:33:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=gKB467sTJt2KSOZTGRdDhs+eENDutAdJrdmOcNmS1cs=; b=OObv7vJHDuimQRvIfHO57MQMxinPFbqeslaLrZaEDHQHG6ZNJ/TU60ZqESLKxH/4LM fkcf2J3Kg5uLM6ci04lk8P3czEtf2xWpZT5qT0yWQv/E4HYHs7znR1nNHsxXxR4j5VNh OcgA60zNLbA8UtrFTpwJftMnRz5qWUiu68gI0xBPHya13ccwRPxdkZ4nIB/SZJJtdCLk l2NKoUZIFmOyYdvNZ5/XV9CiSruFET4Ji+zt/MmkEaJjSVFLTowJmRHkL0IBnA5DIXuJ yPKTl5vfgyD/jnndhj6/EbFZsxiaWpPEHSWmKnlhwUnpNquIrPDb69WnVfGC9vzBYaUz NcFQ== X-Gm-Message-State: AFeK/H0S4mBBdn0TqVYwYQaRoK1JlkMpl3Op0zo5JZUtQSwMUribYiGHdNgeVkuehA5TLLsB9gubLk9SsgEQTQ== X-Received: by 10.28.222.4 with SMTP id v4mr9320373wmg.75.1489404783318; Mon, 13 Mar 2017 04:33:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.47.211 with HTTP; Mon, 13 Mar 2017 04:33:02 -0700 (PDT) In-Reply-To: References: From: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= Date: Mon, 13 Mar 2017 11:33:00 -0000 Message-ID: Subject: Re: Design question LWG 2861: basic_string should require that charT match traits::char_type To: Jonathan Wakely Cc: GCC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2017-03/txt/msg00055.txt.bz2 2017-03-13 11:56 GMT+01:00 Jonathan Wakely : > On 12 March 2017 at 13:21, Daniel Kr=C3=BCgler wrote: >> I'm now working on >> >> http://cplusplus.github.io/LWG/lwg-defects.html#2861 >> >> The new wording state is now equivalent to basic_string_view, whose >> current implementation doesn't bother verifying the requirement, so >> this code (which as UB) currently compiles just fine: >> >> #include >> #include >> >> struct MyTraits : std::char_traits >> { >> typedef unsigned char char_type; >> }; >> >> int main() >> { >> std::basic_string my_string; >> std::basic_string_view my_string_view; >> } >> >> So the least I could do is just - nothing. But it seems to me that we >> could protect users from doing such silly things by adding a >> static_assert to both basic_string and basic_string_view, the former >> being equivalent to >> >> #if __cplusplus >=3D 201103L >> static_assert(__are_same::value, >> "traits_type::char_type must be equal to _CharT"); >> #endif >> >> and the latter an unconditional >> >> static_assert(is_same::value, >> "traits_type::char_type must be equal to _CharT"); >> >> Would you agree with that course of action? > > Not at this stage of gcc7 development. If the silly code compile fine > then we risk breaking working code, and we're too close to a release > to do that. Is there a way to mark a patch suggestion for gcc8 and is so, how? > We can reconsider for gcc8 (but even then, the code has undefined > behaviour, so it would be a QoI choice whether to reject it or just > accept it, as we do for containers where Alloc::value_type doesn't > match the container's value_type). Yes, sure, purely QoI, but the fix seems to be a no-brainer. - Daniel