From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11864 invoked by alias); 24 Apr 2003 13:12:14 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 11853 invoked from network); 24 Apr 2003 13:12:11 -0000 Received: from unknown (HELO synaptics-uk.com) (194.203.111.210) by sources.redhat.com with SMTP; 24 Apr 2003 13:12:11 -0000 Received: from uk_exchange.synaptics-uk.com ([194.203.111.213]) by synaptics-uk.com (8.9.3/8.9.3) with ESMTP id OAA06945; Thu, 24 Apr 2003 14:10:51 +0100 (BST) Received: from dogbert.synaptics-uk.com ([172.20.11.5]) by uk_exchange.synaptics-uk.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id JMMLNZF8; Thu, 24 Apr 2003 14:12:00 +0100 From: Gareth McCaughan To: Ivan Molella Subject: Re: compiler confusion? Date: Thu, 24 Apr 2003 15:12:00 -0000 User-Agent: KMail/1.5 Cc: gcc@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304241411.01100.gmccaughan@synaptics-uk.com> X-SW-Source: 2003-04/txt/msg01230.txt.bz2 Here's a stripped-down version of your code that exhibits the same problem. struct A { A(bool x) {} }; struct C { void f(); }; static int g() { return 1; } void C::f() { A(g() == 100); } Here's what I think is going on: the compiler is seeing that line "A(g() == 100);" as a declaration of a function called g, returning a value of type A. The same as if it said "A g() == 100;". And, of course, when it gets to the "==", that stops making any sense :-). I'm not enough of a C++ standards guru to know whether this behaviour is (1) allowed and/or (2) required. It's weird, certainly, but there are other almost equally ludicrous interpretations that *are* required by the standard. For instance, here's an example from Scott Meyers's "Effective STL". ifstream dataFile("ints.dat"); list data(istream_iterator(dataFile), istream_iterator()); Perhaps contrary to appearances, what this does is to declare a function called "data" taking two arguments: the first is of type istream_iterator and is named "dataFile", and the second is of type "pointer to function from void to istream_iterator" and has no name. :-) -- g