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


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

Re: bug in gcc?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!feeder.news.tin.it!spool.news.tin.it!not-for-mail
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 Fri, 23 Dec 2011 14:50:09 +0100
Message-ID <87ipl7flda.fsf@gmail.com> (permalink)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)
Cancel-Lock sha1:Vei0b3rXLpkpdVG9W7Vvc4LG554=
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Lines 61
Organization TIN.IT (http://www.tin.it)
X-Comments Please send technical notifications to newsmaster@tin.it
NNTP-Posting-Host 79.25.41.212
X-Trace 1324648098 reader1.news.tin.it 1375 79.25.41.212:9610
X-Complaints-To Please send abuse reports to abuse@retail.telecomitalia.it
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:12765

Show key headers only | 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