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 debug/77553] New: [6/7 Regression] wrong code with post-increment operator in constexpr


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

            Bug ID: 77553
           Summary: [6/7 Regression] wrong code with post-increment
                    operator in constexpr
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: trippels at gcc dot gnu.org
  Target Milestone: ---

From
http://stackoverflow.com/questions/39427567/gcc-bug-in-decrement-array-access-in-constexpr


markus@x4 tmp % cat const.ii
constexpr void bar(int *b) {
  int i = 0;
  b[i++] = 1; // GCC failure here.
}

constexpr int foo() {
  int tmp[] = {0};
  bar(tmp);

  return tmp[0];
}

constexpr int cexprI = foo();

int main() {
  static_assert(cexprI, "");
  if (!foo())
    __builtin_abort();
}

markus@x4 tmp % g++ -O2 const.ii
const.ii: In function ‘int main()’:
const.ii:16:3: error: static assertion failed
   static_assert(cexprI, "");
   ^~~~~~~~~~~~~

(With the static_assert commented out:)

markus@x4 tmp % g++ -O2 const.ii
markus@x4 tmp % ./a.out
[1]    25850 abort      ./a.out

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