From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26989 invoked by alias); 4 Dec 2012 07:13:50 -0000 Received: (qmail 26627 invoked by uid 48); 4 Dec 2012 07:12:14 -0000 From: "antoshkka at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55576] Fails to compile a call to template member function Date: Tue, 04 Dec 2012 07:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: antoshkka at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Resolution Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00320.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55576 Antony Polukhin changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID | --- Comment #3 from Antony Polukhin 2012-12-04= 07:12:12 UTC --- (In reply to comment #1) > I don't think this is a G++ bug, there are three problems with this code: >=20 > 1) You need to #include to use placement new > 2) factory::apply is non-const but the parameter 'f' is const Fixed > 3) f.template apply finds the current instantiation, ::apply, rathe= r than > the member function you are trying to call, use f.FactoryT::template appl= y > instead That is the point. `f.template apply(address);` is accepted by some compilers without `FactoryT::` Fixed version: struct factory { template void * apply(void * address) const { return 0; } }; template struct apply { template void* operator()(FactoryT const& f, void * address) const { return f.template apply(address); // error: invalid use of =E2=80=98st= ruct apply=E2=80=99 why??? } }; int main() { int place; apply()(factory(), &place); return 0; }