This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13075] New: bool used as surprising index
- From: "kurt at itlodsen dot dk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Nov 2003 14:43:37 -0000
- Subject: [Bug c++/13075] New: bool used as surprising index
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
We have this ref-counted pointer. The bool value is true unless it is a
null-pointer. Then we introduced a map of strings on this, but this lead to
unexpected results. We narrowed it down to this 7 code line program (leaving the
pointer code aside):
#include <iostream>
using namespace std;
int main()
{
cerr << true["glitch"] << endl;
cerr << false["glitch"] << endl;
}
The program compiles! It prints 'l' and 'g' as if you switched the bool with the
string. I cannot see any practical use of this "feature", and it stops us from
indexing out map-pointer with a string.
--
Summary: bool used as surprising index
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kurt at itlodsen dot dk
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13075