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++/13075] New: bool used as surprising index


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


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