Bug 35087 - g++ fails to compile local class which is passed to template function
Summary: g++ fails to compile local class which is passed to template function
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-05 09:24 UTC by Alexander Zolotarev
Modified: 2008-02-05 10:00 UTC (History)
1 user (show)

See Also:
Host: Linux version 2.6.18-4-k7 (Debian 2.6.18.dfsg.1-12) (waldi@debia
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zolotarev 2008-02-05 09:24:02 UTC
The code example below compiles successfully under Microsoft Visual Studio 2005 SP1.

Minimal steps to reproduce:

-------------------------------------------------
template<typename T> void foo(T &) {}

int main()
{
  struct A
  {
    int m;
  };

  A a;
  foo(a);

  return 0;
}

-----------------------------------------

alexz@alexz-debian:~$ g++ test.cpp
test.cpp: In function 'int main()':
test.cpp:11: error: no matching function for call to 'foo(main()::A&)'

alexz@alexz-debian:~$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Comment 1 Paolo Carlini 2008-02-05 10:00:16 UTC
This is illegal in C++03, per 14.3.1/2, and no strictly conforming compiler accepts it.