971207-g++ parse error with if and while.

Mark Mitchell mmitchell@usa.net
Tue Dec 9 13:04:00 GMT 1997


>>>>> "Dirk" == Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:

    Dirk> Hello everybody!

    Dirk> Please try the following:


    >> cat test.cc
    Dirk> struct X { X(int); operator bool() const; };

    Dirk> int main(int argc, char** argv) { int i = 0; if (X x(i)) ; }
    >> g++ -Wall test.cc
    Dirk> test.cc: In function `int main(int, char **)': test.cc:9:
    Dirk> parse error before `)' test.cc:10: confused by earlier
    Dirk> errors, bailing out



    Dirk> Is there a misunderstanding by me? It doesn't even work for

Yes.  If you look carefully at the standard, you'll see that the
conditon must either an expression, or a 

  type-specifier-seq declarator = assignment-expression

In other words, you must write

  if (X x = i) ;

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu




More information about the Gcc-bugs mailing list