This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/67824] New: constexpr char* compare operations not constexpr, but char[] operations ARE
- From: "erich.keane at intel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 02 Oct 2015 20:00:55 +0000
- Subject: [Bug c/67824] New: constexpr char* compare operations not constexpr, but char[] operations ARE
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67824
Bug ID: 67824
Summary: constexpr char* compare operations not constexpr, but
char[] operations ARE
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: erich.keane at intel dot com
Target Milestone: ---
The below code reproduces this bug, found in 4.9.2, but also reproduced in
5.2.1
Version results for both:
g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
g++ (SUSE Linux) 5.2.1 20150721 [gcc-5-branch revision 226027]
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This code compiles correctly on clang++ 3.5 and 3.6.1.
it seems that the 'root' variable below gets treated correctly, yet the root2,
despite being a valid string as well, doesn't allow pointer operations on it.
This is painful, since it breaks constexpr iterators on constexpr const char*
items.
static constexpr const char root[] = "1234";
static constexpr const char* root2 = "1234";
int main()
{
static_assert(root < root + 1, "This works");
static_assert(root2 < root2 + 1, "This fails");
}