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 Newsgroups: comp.lang.c++ Subject: Re: bug in gcc? References: Date: Fri, 23 Dec 2011 14:50:09 +0100 Message-ID: <87ipl7flda.fsf@gmail.com> 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 "Alf P. Steinbach" writes: > On 23.12.2011 12:04, Timon Gehr wrote: >> g++ fails to compile the following code snippet: >> --- >> struct B{int foo;}; >> >> template 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.