From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id E1E263858027 for ; Fri, 22 Jul 2022 17:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E1E263858027 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-10dc1b16c12so1800127fac.6 for ; Fri, 22 Jul 2022 10:01:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=z8GRrSEDymJwkjP/vIoVA0XVGToRggBTCZHlVaaJWwA=; b=ZYfmL4IvbHmhhVnfrVAGyJvLL6IsPtMvn5VDZuAhVs7JYs+nI18Nt4SzWBD6ZG5kC1 IJ6ieRvM+JFctlVw8rJXR/vySQT8DQ4fkV+ceXA+IViJmElwJJsInI0GN6a4wUbrGSRz s8dzPcBU9qSYxQmE5HF389Vfbh6btgtoAEqy3xi4GebdOWLXjbacdO3JrtUXDhuRsrHF F1MnFzoQ7dM2JMMPxphEg1Yi8c1W0oviy5nIHtvWl+Xxf1DuP9Z6JaFEwBiIZex7IhQl c38Sitm4tBilNx5JCOfeHE8WjNMboa2m27mTVXGIDTS1vpxsbnzoZcDMpporQyOe9LUd MuSA== X-Gm-Message-State: AJIora/0wha280DOrXuaF1Mw2vfMqBLj/DtIoW/EXWImm07NhK+1Je0n H5SpI6HNs9kspgDQ/S+pyrfg0E59i91+yw== X-Google-Smtp-Source: AGRyM1s7cHWM/csTm42amPkeZMftfIFKeVsg6Ek06WLH342cP8oWNbDWgCupK3bnHX+mTQ3dVzoxqQ== X-Received: by 2002:a05:6870:d6aa:b0:10d:a9f8:e5ca with SMTP id z42-20020a056870d6aa00b0010da9f8e5camr3535509oap.135.1658509290201; Fri, 22 Jul 2022 10:01:30 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:8ded:c15d:b142:fa26:49e5? ([2804:431:c7cb:8ded:c15d:b142:fa26:49e5]) by smtp.gmail.com with ESMTPSA id c203-20020aca35d4000000b00339eb701c6csm1410758oia.41.2022.07.22.10.01.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Jul 2022 10:01:29 -0700 (PDT) Message-ID: <59ba8d26-1465-3c9a-b73d-16a01c43f5b5@linaro.org> Date: Fri, 22 Jul 2022 14:01:27 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH v4 2/3] stdlib: Implement mbrtoc8(), c8rtomb(), and the char8_t typedef. Content-Language: en-US To: Tom Honermann , Joseph Myers Cc: libc-alpha@sourceware.org References: <20220630125215.6052-1-tom@honermann.net> <20220630125215.6052-3-tom@honermann.net> <6cf42820-86cb-f3ee-e4cf-3310de2e0bd1@honermann.net> <9940d0fb-0907-7ab2-2dc0-29236fc286a3@honermann.net> <68dad418-f607-e0af-1983-df01ed1e422f@linaro.org> <83387a91-fe6b-ba45-3906-448f2d9c98cd@linaro.org> <9166be9c-bf3e-46f9-d867-e007adc27eb2@linaro.org> <98ac49a5-519c-dd5f-ea0b-e6ad5efdfb59@honermann.net> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <98ac49a5-519c-dd5f-ea0b-e6ad5efdfb59@honermann.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2022 17:01:33 -0000 On 22/07/22 14:00, Tom Honermann wrote: > On 7/22/22 10:15 AM, Adhemerval Zanella Netto wrote: >> >> On 22/07/22 08:21, Adhemerval Zanella Netto wrote: >>> >>> On 22/07/22 02:24, Tom Honermann wrote: >>>> On 7/21/22 4:56 PM, Adhemerval Zanella Netto wrote: >>>>> On 21/07/22 17:51, Tom Honermann wrote: >>>>>> On 7/21/22 3:22 PM, Adhemerval Zanella Netto wrote: >>>>>>> On 20/07/22 13:47, Tom Honermann wrote: >>>>>>>> Confirmed that this issue can be easily reproduced outside the testsuite. >>>>>>>> >>>>>>>> $ cat t.cpp >>>>>>>> #include >>>>>>>> >>>>>>>> $ g++ --version >>>>>>>> g++ (GCC) 13.0.0 20220720 (experimental) >>>>>>>> ... >>>>>>>> >>>>>>>> $ g++ -c -I/path/to/glibc-char8_t/include -std=c++17 -Werror=c++20-compat t.cpp >>>>>>>> In file included from t.cpp:1: >>>>>>>> /home/tom/products/glibc-char8_t/include/uchar.h:38:23: error: identifier ‘char8_t’ is a keyword in C++20 [-Werror=c++20-compat] >>>>>>>>       38 | typedef unsigned char char8_t; >>>>>>>>          |                       ^~~~~~~ >>>>>>>> cc1plus: some warnings being treated as errors >>>>>>>> >>>>>>>> The char8_t typedef is currently guarded by: >>>>>>>> >>>>>>>> /* Declare the C2x char8_t typedef in C2x modes, but only if the C++ >>>>>>>>      __cpp_char8_t feature test macro is not defined.  */ >>>>>>>> #if __GLIBC_USE (ISOC2X) && !defined __cpp_char8_t >>>>>>>> /* Define the 8-bit character type.  */ >>>>>>>> typedef unsigned char char8_t; >>>>>>>> #endif >>>>>>>> >>>>>>>> __GLIBC_USE (ISOC2X) evaluates to true because gcc unconditionally defines _GNU_SOURCE. I believe otherwise, C++17 mode would only (or should only) imply __GLIBC_USE (ISOC11). >>>>>>>> >>>>>>>> Regardless, it seems that directives should be added to suppress the diagnostic. I tried prototyping such a fix, but it doesn't seem to work for me. I don't understand why. >>>>>>> I have tried as well and I can't get to work either.  It would expect to work >>>>>>> as we have done bits/stdlib-bsearch.h, could it be a gcc issue? >>>>>> prereqYes, this appears to be a gcc issue. I spent some time looking at gcc source code, but didn't find anything obvious. I verified the same technique does work to suppress the similar warning issued for use of, e.g., constexpr, as an identifier when -Wc++11-compat is enabled. I found tests that exercise #pragma GCC diagnostic ignored "-Wc++-compat", but none for -Wc++20-compat (or -Wc++11-compat). >>>>>> >>>>>> Tom. >>>>>> >>>>> In any case I think the fix below is the correct way (in fact I don't see >>>>> another way so I am assuming a compiler issue here). >>>> I agree. I debugged gcc tonight and discovered what the problem was. I'll submit a patch to gcc. >>>>> We also need to avoid >>>>> declare the typedef for __cplusplus >= 202002L. >>>> The typedef is already avoided if the __cpp_char8_t feature test macro is defined (builtin char8_t support can be enabled in previous C++ standard modes via the -fchar8_t option). >>> If the compiler preprocessor defined for -std=c++20? I had the impression it is >>> enabled iff -fchar8_t is set. >> I realized now I did not write proper english, I meant to ask if gcc always define >> __cpp_char8_t for -std=c++20 and higher since I had the impression that the >> define is only active iff -fchar8_t is actively used. > > English is hard :) > > For gcc, clang, and MSVC, -std=c++20 (/std:c++20 for MSVC) implies -fchar8_t (/Zc:char8_t), but that feature can be disabled with -fno-char8_t (/Zc:char8_t-). For example: > > $ gcc -E -dM -x c++ -std=c++17 /dev/null | grep __cpp_char8_t > $ gcc -E -dM -x c++ -std=c++17 -fchar8_t /dev/null | grep __cpp_char8_t > #define __cpp_char8_t 201811L > $ gcc -E -dM -x c++ -std=c++20 /dev/null | grep __cpp_char8_t > #define __cpp_char8_t 201811L > $ gcc -E -dM -x c++ -std=c++20 -fno-char8_t /dev/null | grep __cpp_char8_t > > Tom. > Ok, thanks.