This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] For Adding clang check


Hi Florian,
While compiling this (https://godbolt.org/z/uV2Pjp) c++ program with
clang (it uses libstdc++ by default)
static_assert fails.
that is because
this macro  __CORRECT_ISO_CPP_STRING_H_PROTO does not get defined when
clang is used, because it is like this in string.h

#if defined __cplusplus && __GNUC_PREREQ (4, 4)
# define __CORRECT_ISO_CPP_STRING_H_PROTO
#endif


And return type of strchr  in this case is char *, while we expect it
to be const char *.
That does not happen because latter declration is hidden by this macro
__CORRECT_ISO_CPP_STRING_H_PROTO.

I have used clang 3.5  here in check, because this is minimum version
which worked with libc++ and libstdc++.

,kamlesh

On Fri, Nov 29, 2019 at 1:55 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * kamlesh kumar:
>
> > It fixes this.
> > https://bugs.llvm.org/show_bug.cgi?id=44169
>
> What's the rationale for the condition?  What's special about Clang
> 3.5?
>
> My understanding is that a compiler needs support for asm aliases
> *and* the C++ library headers need to be compatible.  Is there a way
> to determine if libc++ is compatible?  For libstdc++ with GCC, the
> compiler version check covers libstdc++ implicity, but that does not
> apply to Clang, or libc++ with either compiler.
>
> > On Fri, Nov 29, 2019 at 12:22 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >>
> >> * Kamlesh Kumar:
> >>
> >> > ChangeLog :
> >> >
> >> > 2019-11-28  Kamlesh Kumar  <kamleshbhalui@gmail.com>
> >> >
> >> >        * string/string.h (__glibc_clang_prereq): Used.
> >> > ---
> >> >  string/string.h | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/string/string.h b/string/string.h
> >> > index 73c22a535a..06a8977165 100644
> >> > --- a/string/string.h
> >> > +++ b/string/string.h
> >> > @@ -33,7 +33,7 @@ __BEGIN_DECLS
> >> >  #include <stddef.h>
> >> >
> >> >  /* Tell the caller that we provide correct C++ prototypes.  */
> >> > -#if defined __cplusplus && __GNUC_PREREQ (4, 4)
> >> > +#if defined __cplusplus && (__GNUC_PREREQ (4, 4) || __glibc_clang_prereq(3,5))
> >> >  # define __CORRECT_ISO_CPP_STRING_H_PROTO
> >> >  #endif
> >>
> >> Sorry, what's the purpose of this change?  Thanks.
> >>
> >> If it fixes a user-visible problem, it should reference a bug in
> >> Bugzilla.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]