This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48911] New: [C++0x]An error that a valid array subscript
- From: "sscrisk at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 6 May 2011 05:54:20 +0000
- Subject: [Bug c++/48911] New: [C++0x]An error that a valid array subscript
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
Summary: [C++0x]An error that a valid array subscript
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sscrisk@gmail.com
Source:
int main()
{
{
constexpr int array[1] = {0};
constexpr int i = array[0]; // OK.
}
{
constexpr int array[1] = {};
constexpr int i = array[0]; // error: array subscript out of bound. Why?
}
}
Compile errors:
a.cpp: In function 'int main()':
a.cpp:5:17: warning: unused variable 'i' [-Wunused-variable]
a.cpp:9:28: error: array subscript out of bound
a.cpp:9:17: warning: unused variable 'i' [-Wunused-variable]
Access to array[0] is valid. But, compiler says "that's an error."