Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #4629

Re: Strange gcc compiler error?

From Victor Bazarov <v.bazarov@comcast.invalid>
Newsgroups comp.lang.c++
Subject Re: Strange gcc compiler error?
Date 2011-05-03 13:09 -0400
Organization A noiseless patient Spider
Message-ID <ippcrt$9bl$1@dont-email.me> (permalink)
References <47dc9f45-a4a5-4b61-aaf2-92c1602cc1cf@i39g2000prd.googlegroups.com> <ippcd5$5a7$1@dont-email.me> <7e9fe42d-aff5-498f-947e-adef658217bd@r27g2000prr.googlegroups.com>

Show all headers | View raw


On 5/3/2011 1:06 PM, J Cook wrote:
> On May 3, 1:01 pm, Victor Bazarov<v.baza...@comcast.invalid>  wrote:
>> On 5/3/2011 12:51 PM, J Cook wrote:
> \>  In order to verify you could usewww.comeaucomputing.com/
> tryitout(they
>> compile but don't link), their compiler is very Standard-compliant.
>>
>> As to your "error" since 'Foo' is the name of the type, the compiler can
>> (and will) interpret
>>
>>       Foo(test);
>>
>> as a declaration of a variable 'test' of type 'Foo', thus trying to
>> redeclare 'test' with another type.  To avoid that add parentheses
>>
>>       Foo((test));
>
> You are right about the semantic confusion.  I had thought of the
> double parenthesis would fix it also, but it does not seem to make any
> difference.  I really want to create an unnamed temporary (a common
> task), and can't seem to find a way to hint the parser that this
> should be a Constructor call with one parameter.

You can do

    static_cast<Foo>(test);

that should invoke the constructor.

V
-- 
I do not respond to top-posted replies, please don't ask

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Strange gcc compiler error? J Cook <joecook@gmail.com> - 2011-05-03 09:51 -0700
  Re: Strange gcc compiler error? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-03 13:01 -0400
    Re: Strange gcc compiler error? J Cook <joecook@gmail.com> - 2011-05-03 10:06 -0700
      Re: Strange gcc compiler error? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-03 13:09 -0400
        Re: Strange gcc compiler error? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-03 13:10 -0400
          Re: Strange gcc compiler error? Öö Tiib <ootiib@hot.ee> - 2011-05-03 10:36 -0700
            Re: Strange gcc compiler error? James Kanze <james.kanze@gmail.com> - 2011-05-03 15:02 -0700
  Re: Strange gcc compiler error? Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-03 19:31 +0200

csiph-web