From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30674 invoked by alias); 11 Jan 2012 21:30:21 -0000 Received: (qmail 30657 invoked by uid 22791); 11 Jan 2012 21:30:20 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Jan 2012 21:30:06 +0000 From: "bugs at sehe dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51829] New: decltype() deduces non-const but only in a template Date: Wed, 11 Jan 2012 21:30: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: bugs at sehe dot nl 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: 2012-01/txt/msg01311.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51829 Bug #: 51829 Summary: decltype() deduces non-const but only in a template Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: bugs@sehe.nl The problem rejects a valid `auto expr = ...;` initialization. I have reduced things to the following (full preprocessed version attached) The template arguments aren't relevant (unused). #include template // without template, works! void bug() { const auto& e1 = boost::spirit::qi::eps(false); const auto& e2 = e1 | '1'; decltype(boost::spirit::qi::eps(false) | '1') *notok; notok = &e2; // FAILS if in template function } int main() { bug(); } By using a pointer declaration for `notok` I was able to use demangling to print the difference between the deduced types: boost::proto::exprns_::expr > >, 0l> const&, boost::proto::exprns_::expr, 0l> >, 2l> boost::proto::exprns_::expr > >, 0l> CONST&, boost::proto::exprns_::expr, 0l> >, 2l> const* The 'CONST' I capitalized in the middle, is missing when the decltype() is in a function template, which prevents the assignment. I don't know how to further reduce the testcase at this point in time. MSVC 2010 compiles the code without problem.