From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 2B21038346B2 for ; Tue, 10 May 2022 13:27:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B21038346B2 Received: by mail-wr1-x436.google.com with SMTP id b19so23810787wrh.11 for ; Tue, 10 May 2022 06:27:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Ci/oYCADw0lt2wYHZbTWGMmWzwawjUBvrtJltdOKFfM=; b=w7K099kAppd5zm2FB8BzeqES9lI/voIBy2llGPeZn1vHUv7C1cyEJ3dLvI7SFITbbv LmXpl8rVfzsdzSRAwG4RfOrrk8AZRN5MB3r5yxkz8o7tA+zisx7D1gpQZoXVjkv7dA9O K0MnTuzX0fIpjuBl34y0/D/q9ikjnkAi+q7b9oIAVss+iaxbiLHP+5lyCOJbla8mUR6m TFJxFzpGB7cSo7oDTTGvt2WkaKeSJZ10AVCxVmW/IMq56WYUNYKApam9ZK1iNfXZif/1 GtGm5AsXQWBcgd//F6bCS0I/lf9f8YSjIxt5XmUq+otnjU0ZJJvhZW4mV8/COoUBKCkU pG2Q== X-Gm-Message-State: AOAM530HnJlBBQYuAmntCN/Yd2lOrwVA+8uUBcwKtuC3w7EMZVKiXNKc 1Av1rCgqOvhO+NBGcIaMC7gk5lecz7xdl/GnAJQ= X-Google-Smtp-Source: ABdhPJzcTG5YQzl4u0rC9wJU+HAEeIdxClVdiUwbNIeL0vj+7hRZPrawvfughEEwdnoTlJxCCWYUmP++2sFItQcanqs= X-Received: by 2002:a5d:4806:0:b0:20a:da03:711b with SMTP id l6-20020a5d4806000000b0020ada03711bmr18273292wrq.395.1652189243806; Tue, 10 May 2022 06:27:23 -0700 (PDT) MIME-Version: 1.0 References: <87wnevcb0f.fsf@oldenburg.str.redhat.com> <87levbkoj4.fsf@igel.home> In-Reply-To: <87levbkoj4.fsf@igel.home> From: Jonathan Wakely Date: Tue, 10 May 2022 14:27:12 +0100 Message-ID: Subject: Re: -Wformat and u8"" To: Andreas Schwab Cc: Florian Weimer via Gcc , Florian Weimer , Ulrich Drepper Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 13:27:26 -0000 On Mon, 9 May 2022 at 11:09, Andreas Schwab wrote: > > On Mai 09 2022, Florian Weimer via Gcc wrote: > > > * Ulrich Drepper via Gcc: > > > >> t.cc: In function =E2=80=98int main()=E2=80=99: > >> t.cc:5:24: warning: format string is not an array of type =E2=80=98cha= r=E2=80=99 [-Wformat=3D] > >> 5 | printf((const char*) u8"test %d\n", 1); > >> | ^~~~~~~~~~~~~ > > > > This is not an aliasing violation because of the exception for char, > > right? So the warning does not even highlight theoretical undefined > > behavior. > > > > On the other hand, that cast is still quite ugly. All string-related > > functions in the C library currently need it. It might obscure real > > type errors. Isn't this a problem with char8_t? > > In C++20, u8 literals have a distinct type, which is an incompatible > change from C++17. And the recommended way to deal with it is to use a cast as Ulrich did.