[Bug c++/13075] New: bool used as surprising index
kurt at itlodsen dot dk
gcc-bugzilla@gcc.gnu.org
Sun Nov 16 14:43:00 GMT 2003
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
More information about the Gcc-bugs
mailing list