This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54543] New: Expression (condition ? array : throw expr)[index] fails to compile
- From: "tsoae at mail dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 10 Sep 2012 17:31:16 +0000
- Subject: [Bug c++/54543] New: Expression (condition ? array : throw expr)[index] fails to compile
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54543
Bug #: 54543
Summary: Expression (condition ? array : throw expr)[index]
fails to compile
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tsoae@mail.ru
g++ 4.8.0 20120909 (experimental) fails to compile the following well-defined
code:
int f(int (&arr)[10], int n)
{
return ((0 <= n && n < 10) ? arr : throw "error")[n];
}
int main() {}
COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic'
'-march=pentiumpro'
test.cpp: In function âint f(int (&)[10], int)â:
test.cpp:3:46: error: void value not ignored as it ought to be
return ((0 <= n && n < 10) ? arr : throw "error")[n];
^
Compiler version info:
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=../target --enable-languages=c,c++
Thread model: posix
GNU C++ (GCC) version 4.8.0 20120909 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 4.8.0 20120909 (experimental), GMP version 5.0.2,
MPFR version 3.1.0, MPC version 0.8.2