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++/48911] New: [C++0x]An error that a valid array subscript


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."


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