From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35245 invoked by alias); 13 Mar 2017 17:31:27 -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 35226 invoked by uid 89); 13 Mar 2017 17:31:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*i:sk:5RJ1FMr, H*f:CAGNvRgC08jD8Qa, H*i:CAGNvRgC08jD8Qa, H*f:sk:5RJ1FMr X-HELO: mail-yw0-f174.google.com Received: from mail-yw0-f174.google.com (HELO mail-yw0-f174.google.com) (209.85.161.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Mar 2017 17:31:25 +0000 Received: by mail-yw0-f174.google.com with SMTP id o4so63727589ywd.3 for ; Mon, 13 Mar 2017 10:31:25 -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=UNI/xo233yk204hlHHx0ck1PcvLSECkO/eTTllNExrE=; b=hvdNYGWVWXqM13sDVtrlo9w6Y892qBUMdsbBeyj3oYN/aPXteJQxFjXNRccfLPtat9 x/txSJl90DTp38QDOI+ldg3/2gXA0jfZrlCNnt2tzoJfSdkyafLZfZ9NyOSo3fKhG8dX Wrfjc3dE681op3UrnxA28lSlpEUy2Mjc56XW1WMQ9vMIHRn8rl/Bp4eIwVj/VoCCE41I MCkvwEnhzPBQLppYUbke+YG6D1Sb/4VXkMHJxXPrcV2x/mkEIK0pzyfLtsd/Sce6X/xV 5qCoid4o4/7q4VaST/Qdw43OOBdiHq1uUE9f/pBaPcQfw8tfIIdF6lsHmm7y7YNHwc5f QLXA== X-Gm-Message-State: AMke39lpo2WIGiXkN6TiNnmHdF9ppMz2LQnfxEgxe5iXTF5VH6ilrj87YwTqBc7SzisNamtDezA8k6xM4jis/Q== X-Received: by 10.37.164.6 with SMTP id f6mr17903270ybi.146.1489426284213; Mon, 13 Mar 2017 10:31:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.164.36 with HTTP; Mon, 13 Mar 2017 10:31:23 -0700 (PDT) In-Reply-To: References: From: Jonathan Wakely Date: Mon, 13 Mar 2017 17:31:00 -0000 Message-ID: Subject: Re: Design question LWG 2861: basic_string should require that charT match traits::char_type To: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= Cc: GCC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00059.txt.bz2 On 13 March 2017 at 11:33, Daniel Kr=C3=BCgler = wrote: > 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? Just mention it in the email. Ideally ping the patch after gcc7 is released so someone (probably me) can apply it once we're back in Stage 1.