This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c++/71457] New: valid pointer plus conversion to bool rejected in constexpr context


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71457

            Bug ID: 71457
           Summary: valid pointer plus conversion to bool rejected in
                    constexpr context
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC rejects both of the following valid constant expressions (Clang accepts
both):

$ cat zzz.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B
/home/msebor/build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -xc++ zzz.c
constexpr bool f ()
{
  int i = 1;
  return &i + 1;
}

constexpr bool b0 = f ();

constexpr bool b1 = "abc" + 1;

zzz.c:4:15: error: â(((& i) + 4u) != 0u)â is not a constant expression
   return &i + 1;
               ^
zzz.c:9:29: error: â((((const char*)"abc") + 1u) != 0u)â is not a constant
expression
 constexpr bool b1 = "abc" + 1;
                             ^

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