From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 729 invoked by alias); 16 Jan 2013 15:13:45 -0000 Received: (qmail 560 invoked by uid 48); 16 Jan 2013 15:13:22 -0000 From: "david.irvine at maidsafe dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56004] New: Possible bug with decltype and access modifer order Date: Wed, 16 Jan 2013 15:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david.irvine at maidsafe dot net 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: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" 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: 2013-01/txt/msg01517.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56004 Bug #: 56004 Summary: Possible bug with decltype and access modifer order Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: david.irvine@maidsafe.net Please see this stackoverflow question for an overview. http://stackoverflow.com/questions/14188535/clang-access-modifier-order-and-decltype The issue seems to be that the private members are not visible at compilation to the decltype call. This is a minimum example (from the question). (I am the questioner in this case). This also seems to appear as a 'bug' in gcc but not msvc (12). I am not 100% convinced but cannot find in the standard why this will not work. I hope this helps. #include #include #include #include template T &self(T &t) { return t; } template struct Dependent { }; template class Synchronised : Dependent{ public: explicit Synchronised(T t = T()) : t_(t) {} template auto operator()(Functor functor) const ->decltype(functor(self(*this).t_)) { //auto operator()(Functor functor) const ->decltype(functor(this->t_)) { std::lock_guard lock(mutex_); return functor(t_); } private: mutable T t_; mutable std::mutex mutex_; }; int main() { Synchronised sync_string("Start\n"); std::vector> futures; }