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


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

Re: bug in gcc?

From Marco Minutoli <mminutoli@gmail.com>
Newsgroups comp.lang.c++
Subject Re: bug in gcc?
References <d304891e-05dc-44f1-9df0-19ada4117dbb@g41g2000yqa.googlegroups.com> <jd1olu$1ge$1@dont-email.me>
Date 2011-12-23 14:50 +0100
Message-ID <87ipl7flda.fsf@gmail.com> (permalink)
Organization TIN.IT (http://www.tin.it)

Show all headers | View raw


"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:

> On 23.12.2011 12:04, Timon Gehr wrote:
>> g++ fails to compile the following code snippet:
>> ---
>> struct B{int foo;};
>>
>> template<class T>  int foo(T x){
>>      int y = x.foo<1>(0);
>>      return y;
>> }
>>
>> int main(){
>>      int c = foo(B());
>> }
>> ---
>> ---
>> bug.cpp: In function ‘int foo(T) [with T = B]’:
>> bug.cpp:10:17:   instantiated from here
>> bug.cpp:5:20: error: ‘foo’ is not a member template function
>> ---
>>
>> The code compiles if the template function is renamed from 'foo' to
>> 'bar'.
>>
>> Is this a bug?
>
> If it's true that it compiles with the simple renaming, then yes.
>
> However, your posting is rather unclear.
>
> Why on Earth are you showing the non-problematic code instead of the
> code where there is possibly a problem?
>

To me this looks like the problematic code :).

When we have the template function named bar the line:
int y = x.foo<1>(0);

is interpreted as:
int y = (x.foo<1)>(0);

What is not clear to me is why naming foo the template function change
this behavior.

BTW I have tested it with both g++ and clang++ and both behave in the
same way.

> Given the lack of logic in the posting, I think it's more likely that
> you're confused about this.
>
> I.e., a PEBKAC problem.
>
>
> Cheers & hth.,
>
> - Alf

Cheers,
Marco.

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


Thread

bug in gcc? Timon Gehr <timon.gehr@gmail.com> - 2011-12-23 03:04 -0800
  Re: bug in gcc? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2011-12-23 12:28 +0100
    Re: bug in gcc? Timon Gehr <timon.gehr@gmail.com> - 2011-12-23 04:33 -0800
    Re: bug in gcc? Rui Maciel <rui.maciel@gmail.com> - 2011-12-23 13:21 +0000
      Re: bug in gcc? Timon Gehr <timon.gehr@gmail.com> - 2011-12-23 05:36 -0800
    Re: bug in gcc? Marco Minutoli <mminutoli@gmail.com> - 2011-12-23 14:50 +0100
      Re: bug in gcc? Rui Maciel <rui.maciel@gmail.com> - 2011-12-23 14:14 +0000
        Re: bug in gcc? Timon Gehr <timon.gehr@gmail.com> - 2011-12-23 06:30 -0800
  Re: bug in gcc? jacob navia <jacob@spamsink.net> - 2011-12-23 14:43 +0100
  Re: bug in gcc? Johannes Schaub <schaub.johannes@googlemail.com> - 2011-12-24 17:22 +0100
    Re: bug in gcc? Miles Bader <miles@gnu.org> - 2011-12-25 11:36 +0900

csiph-web