constexprintm=strlen("hello");// expected-error {{constant expression}} expected-note {{non-constexpr function 'strlen' cannot be used in a constant expression}}
// Make sure we can evaluate a call to strlen.
intarr[3];// expected-note {{here}}
intk=arr[strlen("hello")];// expected-warning {{array index 5}}
static_assert(__builtin_strcmp(0,"abab")==0);// expected-error {{not an integral constant}} expected-note {{dereferenced null}}
static_assert(__builtin_strcmp("abab",0)==0);// expected-error {{not an integral constant}} expected-note {{dereferenced null}}
static_assert(__builtin_strcmp(kFoobar,kFoobazfoobar)==-1);// FIXME: Should we reject this?
static_assert(__builtin_strcmp(kFoobar,kFoobazfoobar+6)==0);// expected-error {{not an integral constant}} expected-note {{dereferenced one-past-the-end}}
static_assert(__builtin_strncmp(kFoobar,kFoobazfoobar+6,7)==0);// expected-error {{not an integral constant}} expected-note {{dereferenced one-past-the-end}}
static_assert(__builtin_memcmp("abab\0banana","abab\0banana",100)==0);// expected-error {{not an integral constant}} expected-note {{dereferenced one-past-the-end}}
static_assert(__builtin_memcmp("abab\0banana","abab\0canada",100)==-1);// FIXME: Should we reject this?
constexprinta=strcmp("hello","world");// expected-error {{constant expression}} expected-note {{non-constexpr function 'strcmp' cannot be used in a constant expression}}
constexprintb=strncmp("hello","world",3);// expected-error {{constant expression}} expected-note {{non-constexpr function 'strncmp' cannot be used in a constant expression}}
constexprintc=memcmp("hello","world",3);// expected-error {{constant expression}} expected-note {{non-constexpr function 'memcmp' cannot be used in a constant expression}}
static_assert(__builtin_memchr(kFoo,'x',4)==nullptr);// expected-error {{not an integral constant}} expected-note {{dereferenced one-past-the-end}}
static_assert(__builtin_memchr(nullptr,'x',3)==nullptr);// expected-error {{not an integral constant}} expected-note {{dereferenced null}}
static_assert(__builtin_memchr(nullptr,'x',0)==nullptr);// FIXME: Should we reject this?
constexprboola=!strchr("hello",'h');// expected-error {{constant expression}} expected-note {{non-constexpr function 'strchr' cannot be used in a constant expression}}
constexprboolb=!memchr("hello",'h',3);// expected-error {{constant expression}} expected-note {{non-constexpr function 'memchr' cannot be used in a constant expression}}