From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23677 invoked by alias); 16 Jan 2013 18:17:14 -0000 Received: (qmail 23636 invoked by uid 48); 16 Jan 2013 18:16:59 -0000 From: "david.irvine at maidsafe dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56004] Possible bug with decltype and access modifer order Date: Wed, 16 Jan 2013 18:17: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: 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: In-Reply-To: References: 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/msg01549.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56004 --- Comment #4 from David Irvine 2013-01-16 18:16:58 UTC --- I see In my case in a simpler version than posted this compiles fine template class Synchronised { public: Synchronised(T t = T{}) : t_{t} {} template auto operator()(F f) const -> decltype(f(t_)) { std::lock_guard lock{mutex_}; return f(t_); } private: // place this before public: and this object compiles mutable T t_; mutable std::mutex mutex_; }; Fails and swapping private to be declared before public works ! as below This will not compile template class Synchronised { private: // place this before public: and this object compiles mutable T t_; mutable std::mutex mutex_; public: Synchronised(T t = T{}) : t_{t} {} template auto operator()(F f) const -> decltype(f(t_)) { std::lock_guard lock{mutex_}; return f(t_); } }; I think you are saying the same thing but this is what I mean by private coming before public (changing accessors or their order). I think it is the only situation I have encountered this.