public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pierhyth at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/24702] New: Koenig found functoid ref, but "cannot be used as a function" Date: Mon, 07 Nov 2005 07:09:00 -0000 [thread overview] Message-ID: <bug-24702-11665@http.gcc.gnu.org/bugzilla/> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2662 bytes --] The problem relates to functoid objects ("function like" objects, ie ones with an operator() defined) and references to them within a namespace. When Koenig lookup is used to find such a reference-to-functoid, g++ seems to find it okay, but then states "cannot be used as a function". If I use an actual functoid object instead of a reference to one, it works fine. Here is an example: #include <iostream> namespace dummyx { struct Dummy { Dummy() {} }; struct DummyFunct { int operator()(Dummy d) const {return 5;} static DummyFunct& full() {static DummyFunct f; return f;} }; static DummyFunct& dummyFunct=DummyFunct::full(); DummyFunct myDummyFunct; DummyFunct& mymyDummyFunct=myDummyFunct; } int main() { ::dummyx::Dummy const d; std::cout<<"dummyx::dummyFunct(d) = "<<dummyx::dummyFunct(d)<<std::endl; std::cout<<"dummyFunct(d) = "<<dummyFunct(d)<<std::endl; // fails with 3.4 and 4.0 std::cout<<"myDummyFunct(d) = "<<myDummyFunct(d)<<std::endl; std::cout<<"mymyDummyFunct(d) = "<<mymyDummyFunct(d)<<std::endl; // fails with 3.4 and 4.0 } When I try to compile this code using g++ version 4.0.2 I get the following errors: testit.cc: In function int main(): testit.cc:26: error: dummyx::dummyFunct cannot be used as a function testit.cc:28: error: dummyx::mymyDummyFunct cannot be used as a function I see no reason why such references should not be able to be used as a function. As you see, if it is explicitly namespace-qualified it can be. And according to Koenig rules, the unqualified name should indeed be found and, as operator() is applicable for the found reference, it should be usable as a function. Indeed, this is what version 3.2.3 of g++ does. The above test code compiles fine with g++ version 3.2.3. The errors seem only to occur in versions 3.4 and later (certainly they occur for versions 3.4.5 and 4.0.2.) Additional version information: g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20) g++-3.4 (GCC) 3.4.5 20050809 (prerelease) (Ubuntu 3.4.4-6ubuntu8) g++-4.0 (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9) -- Summary: Koenig found functoid ref, but "cannot be used as a function" Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pierhyth at gmail dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24702
next reply other threads:[~2005-11-07 7:09 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-11-07 7:09 pierhyth at gmail dot com [this message] 2005-11-07 13:37 ` [Bug c++/24702] " pinskia at gcc dot gnu dot org 2005-11-09 1:33 ` pierhyth at gmail dot com 2005-11-16 19:28 ` gdr at integrable-solutions dot net 2005-12-04 5:09 ` gdr at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-24702-11665@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).