This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/77553] New: [6/7 Regression] wrong code with post-increment operator in constexpr
- From: "trippels at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 10 Sep 2016 21:00:21 +0000
- Subject: [Bug debug/77553] New: [6/7 Regression] wrong code with post-increment operator in constexpr
- Auto-submitted: auto-generated
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