From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 88F961F4B4 for ; Fri, 15 Jan 2021 12:21:57 +0000 (UTC) Received: from localhost ([::1]:40976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0O72-00031Y-C6 for normalperson@yhbt.net; Fri, 15 Jan 2021 07:21:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0O4d-0000cP-Jf for bug-gnulib@gnu.org; Fri, 15 Jan 2021 07:19:27 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:36573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0O4a-0000nI-TF for bug-gnulib@gnu.org; Fri, 15 Jan 2021 07:19:27 -0500 Received: by mail-wr1-x436.google.com with SMTP id 6so1766305wri.3 for ; Fri, 15 Jan 2021 04:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=p4PmXuSAzkZWmj9wYfO2J3OBUloJePrhU5jy/BweGok=; b=HQO2Nw/8l0OWCau18WAcCa5G+yHEATwVQj5u64KK0A145gNaouVLDzNaj7yK7mA8fV BFhEXOPGdUXtOyz8/KFVoJArAplTIPrdSPu8t2e8rdzWoaXC3AK44LFQC5fkCDu2AIQx ZIFIlMojdf8UsrYAWGOqF1M4zQ6VPMTb/2nGfQ4qxYQL1hx4wQ21YxpvyCbaQAvcf4XQ hHxpOjw/eFq98p3kYCFkwhEnkvoJnEXynDOaT0WmeVh6HX9MfffBfA82/kdEfOsjOiUC HtxNQkh37ntVQZqJE4Oyng+RWVc/iCkJn8ijoH8U0zouOmmA29JkhUxfHB8asRT29l8n +oBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=p4PmXuSAzkZWmj9wYfO2J3OBUloJePrhU5jy/BweGok=; b=jZG3TgcMmC8wvm/sCjovYWK4N835AinSFwNg5S/QX2mVFMHh1L4zCGztBOEjtKrr9O ocegsjo1bBU3ukh6g8ydAaPg7lSjTpo5n6BrYDHltvzPvmx/rXhsVPi+/XRDw7QuEP/u S7D9oRt/cjll2IZvgdGgCFD0iM+0EuxQTiMim+GQUlC41qfR6/GSpTOV7TEnRGrHpo11 /QIEaYorNdexoIBEXhvzA1uHWUOPFzgJOJjmQMrd+/g8Tw+khQrFkFpYrCNbrvzd9npX 3GoT7jLK+NK3tRFiat2qjcnXfLiDa4ftdEOKtO31csAqoB/GMTi78/1pBFPNfOkqW2xv ZdzA== X-Gm-Message-State: AOAM5326jRm8MNr/4eyNxI06vg0pZZ5ITbFUFLrjQsFg5q/G24azRsji DS9tFjShg++tinVqilNzme4GJ+3QocQ/Yw== X-Google-Smtp-Source: ABdhPJwhS9boe51vnHEob/x5y4pTxaoNkPAShymFNvlvgHulrzqTJxqBS22HG+wgor5KxDTD8G2GCw== X-Received: by 2002:a5d:4587:: with SMTP id p7mr12443570wrq.178.1610713163085; Fri, 15 Jan 2021 04:19:23 -0800 (PST) Received: from goulash (89-109-190-109.dsl.ovh.fr. [109.190.109.89]) by smtp.gmail.com with ESMTPSA id 125sm12386156wmc.27.2021.01.15.04.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 04:19:22 -0800 (PST) From: Alexandre Duret-Lutz To: Bruno Haible Subject: Re: clang++ hard failure with GNULIB_NAMESPACE References: <87turkvkud.fsf@lrde.epita.fr> <87eein6c2b.fsf@lrde.epita.fr> <87o8hrfxbw.fsf_-_@lrde.epita.fr> <3481842.QgHHNxatZX@omega> Date: Fri, 15 Jan 2021 13:19:21 +0100 In-Reply-To: <3481842.QgHHNxatZX@omega> (Bruno Haible's message of "Fri, 15 Jan 2021 10:51:02 +0100") Message-ID: <87r1mmtmt2.fsf@lrde.epita.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=aduret@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Bruno Bruno Haible writes: >> Using clang++ 11, compilation fails because of the overloads of memchr >> and friends. >> >> In file included from bitvect.cc:28: >> In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstring:42: >> ../../lib/string.h:693:1: error: reference to overloaded function >> could not be resolved; did you mean to call it? >> _GL_CXXALIASWARN (memchr); >> ^~~~~~~~~~~~~~~~~~~~~~~~~ > > On which version of glibc do you see this? This is the glibc packaged as "libc6 2.31-9" in Debian unstable. > On my machine, the testdir created through > $ ./gnulib-tool --create-testdir --dir=../testdir4 > --single-configure --with-c++-tests memchr rawmemchr strchrnul > > compiles fine with clang 11 and these environment variable settings: > > CC=$HOME/inst-clang/11.0.0/bin/clang > CXX="$HOME/inst-clang/11.0.0/bin/clang++ > -L/usr/lib/gcc/x86_64-linux-gnu/5 -I/usr/include/c++/5 > -I/usr/include/x86_64-linux-gnu/c++/5" > export CC CXX > > Does this same testdir work for you? No, the command ./configure CXX=clang++ && make fails as follows: clang++ -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib -I./../gllib -g -O2 -MT test-string-c++.o -MD -MP -MF .deps/test-string-c++.Tpo -c -o test-string-c++.o test-string-c++.cc In file included from test-string-c++.cc:22: ../gllib/string.h:693:1: error: reference to overloaded function could not be resolved; did you mean to call it? _GL_CXXALIASWARN (memchr); ^~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:365:4: note: expanded from macro '_GL_CXXALIASWARN' _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:367:4: note: expanded from macro '_GL_CXXALIASWARN_1' _GL_CXXALIASWARN_2 (func, namespace) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:372:5: note: expanded from macro '_GL_CXXALIASWARN_2' _GL_WARN_ON_USE (func, \ ^~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:535:19: note: expanded from macro '_GL_WARN_ON_USE' extern __typeof__ (function) function \ ^~~~~~~~~~ /usr/include/string.h:84:1: note: possible target for call memchr (const void *__s, int __c, size_t __n) __THROW ^ /usr/include/string.h:78:1: note: possible target for call memchr (void *__s, int __c, size_t __n) __THROW ^ In file included from test-string-c++.cc:22: ../gllib/string.h:807:1: error: reference to overloaded function could not be resolved; did you mean to call it? _GL_CXXALIASWARN (rawmemchr); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:365:4: note: expanded from macro '_GL_CXXALIASWARN' _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:367:4: note: expanded from macro '_GL_CXXALIASWARN_1' _GL_CXXALIASWARN_2 (func, namespace) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:372:5: note: expanded from macro '_GL_CXXALIASWARN_2' _GL_WARN_ON_USE (func, \ ^~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:535:19: note: expanded from macro '_GL_WARN_ON_USE' extern __typeof__ (function) function \ ^~~~~~~~~~ /usr/include/string.h:101:26: note: possible target for call extern "C++" const void *rawmemchr (const void *__s, int __c) ^ /usr/include/string.h:99:20: note: possible target for call extern "C++" void *rawmemchr (void *__s, int __c) ^ In file included from test-string-c++.cc:22: ../gllib/string.h:911:1: error: reference to overloaded function could not be resolved; did you mean to call it? _GL_CXXALIASWARN (strchrnul); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:365:4: note: expanded from macro '_GL_CXXALIASWARN' _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:367:4: note: expanded from macro '_GL_CXXALIASWARN_1' _GL_CXXALIASWARN_2 (func, namespace) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:372:5: note: expanded from macro '_GL_CXXALIASWARN_2' _GL_WARN_ON_USE (func, \ ^~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/string.h:535:19: note: expanded from macro '_GL_WARN_ON_USE' extern __typeof__ (function) function \ ^~~~~~~~~~ /usr/include/string.h:263:26: note: possible target for call extern "C++" const char *strchrnul (const char *__s, int __c) ^ /usr/include/string.h:261:20: note: possible target for call extern "C++" char *strchrnul (char *__s, int __c) ^ 3 errors generated. make[4]: *** [Makefile:1542: test-string-c++.o] Error 1 > If I can't reproduce it, I'll have to ask you for appropriate modifications > of gnulib/lib/string.in.h that make things for work you. >From what I understand, the problem is that: 1) my version of string.h has two definitions of memchr for clang, 2) the following snippet assumes that g++ < 4.4 should only see one, regardless of the glibc version 3) clang++ masquerade as g++ 4.2.1 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); _GL_CXXALIASWARN1 (memchr, void const *, (void const *__s, int __c, size_t __n)); # elif __GLIBC__ >= 2 _GL_CXXALIASWARN (memchr); # endif As a first approximation, I tried to simply change the condition to # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __clang__) but doing so still fail with In file included from test-string-c++.cc:22: ../gllib/string.h:689:20: error: 'memchr' is missing exception specification 'throw()' _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); ^ /usr/include/string.h:78:1: note: previous declaration is here memchr (void *__s, int __c, size_t __n) __THROW ^ In file included from test-string-c++.cc:22: ../gllib/string.h:690:20: error: 'memchr' is missing exception specification 'throw()' _GL_CXXALIASWARN1 (memchr, void const *, ^ /usr/include/string.h:84:1: note: previous declaration is here memchr (const void *__s, int __c, size_t __n) __THROW ^ The relevant definitions of memchr in my copy of /usr/include/string.h 35 /* Tell the caller that we provide correct C++ prototypes. */ 36 #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \ 37 || __glibc_clang_prereq (3, 5)) 38 # define __CORRECT_ISO_CPP_STRING_H_PROTO 39 #endif .. 67 /* Search N bytes of S for C. */ 68 #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO 69 extern "C++" 70 { 71 extern void *memchr (void *__s, int __c, size_t __n) 72 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1)); 73 extern const void *memchr (const void *__s, int __c, size_t __n) 74 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1)); 75 76 # ifdef __OPTIMIZE__ 77 __extern_always_inline void * 78 memchr (void *__s, int __c, size_t __n) __THROW 79 { 80 return __builtin_memchr (__s, __c, __n); 81 } 82 83 __extern_always_inline const void * 84 memchr (const void *__s, int __c, size_t __n) __THROW 85 { 86 return __builtin_memchr (__s, __c, __n); 87 } 88 # endif 89 } 90 #else 91 extern void *memchr (const void *__s, int __c, size_t __n) 92 __THROW __attribute_pure__ __nonnull ((1)); 93 #endif If I preprocess the file, I can see the __THROW expands to "throw ()", but that's the case for g++ as well. The reason for the "g++ 4.4" threshold was that initially the definition of __CORRECT_ISO_CPP_STRING_H_PROTO used only that: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d8387c7b7b1c9ae92f924c33ba05790c98464d19 The change to the current definition is one year old: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=953ceff17a4a15b10cfdd5edc3c8cae4884c8ec3 I have reproduced these errors with clang++ 9, 10, and 11, but that should not be surprising if __CORRECT_ISO_CPP_STRING_H_PROTO is enabled for clang++ >= 3.5. -- Alexandre Duret-Lutz