public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "thiago at kde dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66671] New: Failure to create a new family of templates for template alias Date: Thu, 25 Jun 2015 18:20:00 -0000 [thread overview] Message-ID: <bug-66671-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66671 Bug ID: 66671 Summary: Failure to create a new family of templates for template alias Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thiago at kde dot org Target Milestone: --- Whenever you use: template <typename T> using Z = Y<T>; The template Z is different from Y and should be encoded separately. This can be seen in the example: ==== #include <iostream> template <template <typename> class> struct X { X() { std::cout << "1"; } }; template <typename> struct Y {}; template <typename T> using Z = Y<T>; template <> struct X<Y> { X() { std::cout << "2"; } }; int main() { X<Y> x1; X<Z> x2; } ==== (from: http://cppquiz.org/quiz/giveup/117) With GCC 5.1.1, the above prints "22", whereas it prints "21" with ICC 16, Clang 3.7 and MSVC 2013. The explanation from the quiz site is given as: > According to §14.5.7¶1 in the standard, a template alias declaration > resolve to a new family of types. The specialization cannot be used, > and the first template delcaration is used instead, printing 1. Disassembly with -O2 -fno-inline shows that Clang and ICC both call different template specialisations of template class X: leaq 16(%rsp), %rdi callq _ZN1XI1YEC2Ev ; X<Y>::X() leaq 8(%rsp), %rdi callq _ZN1XI1ZEC2Ev ; X<Z>::X() PS: should X<Z> count as a local type or a global one? >From gcc-bugs-return-490214-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 18:47:23 2015 Return-Path: <gcc-bugs-return-490214-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 92361 invoked by alias); 25 Jun 2015 18:47:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: <gcc-bugs.gcc.gnu.org> List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/> List-Post: <mailto:gcc-bugs@gcc.gnu.org> List-Help: <mailto:gcc-bugs-help@gcc.gnu.org> Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 92323 invoked by uid 48); 25 Jun 2015 18:47:19 -0000 From: "thiago at kde dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66672] New: std::is_same wrong result for captured reference value inside a lambda Date: Thu, 25 Jun 2015 18:47: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-Version: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thiago at kde dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: <bug-66672-4@http.gcc.gnu.org/bugzilla/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02546.txt.bz2 Content-length: 1850 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66672 Bug ID: 66672 Summary: std::is_same wrong result for captured reference value inside a lambda Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thiago at kde dot org Target Milestone: --- Given the following code: ==== #include <iostream> #include <type_traits> using namespace std; int main() { int i, &j = i; [=] { cout << is_same<decltype((j)), int &>::value << is_same<decltype((j)), int const&>::value; }(); } ==== (trimmed from http://cppquiz.org/quiz/question/127) With GCC 5.1, the code will print 10, but it should be 01. Clang 3.6, ICC 16 and MSVC 2015 do compile this as expected. The output 10 would be correct if the extra set of parentheses weren't there. The explanation given on the quiz website is: > Since the expression for decltype is a parenthesized lvalue > expression, §7.1.6.2¶4 has this to say: "The type denoted by > decltype(e) is (...) T&, where T is the type of e;" As the > expression occurs inside a const member function, the expression is > const, and decltype((j)) denotes int const&. See also the example in > §5.1.2¶18. [NB: it's paragraph 19 as of N4431] The example in that paragraph of the standard matches almost exactly the code above. The output is correct with a functor: ==== struct S { S(int &i) : j(i) {} void operator()() const { cout << is_same<decltype((j)), int &>::value << is_same<decltype((j)), int const&>::value; }; int j; // captured by value }; int main() { int i; S{i}(); } ==== >From gcc-bugs-return-490215-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 18:49:06 2015 Return-Path: <gcc-bugs-return-490215-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 95475 invoked by alias); 25 Jun 2015 18:49:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: <gcc-bugs.gcc.gnu.org> List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/> List-Post: <mailto:gcc-bugs@gcc.gnu.org> List-Help: <mailto:gcc-bugs-help@gcc.gnu.org> Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 95392 invoked by uid 48); 25 Jun 2015 18:49:02 -0000 From: "joe.carnuccio at qlogic dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/39121] strange behavior in chained operations Date: Thu, 25 Jun 2015 18:49: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-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: joe.carnuccio at qlogic dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-39121-4-BHpAQ5GWJy@http.gcc.gnu.org/bugzilla/> In-Reply-To: <bug-39121-4@http.gcc.gnu.org/bugzilla/> References: <bug-39121-4@http.gcc.gnu.org/bugzilla/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02547.txt.bz2 Content-length: 579 https://gcc.gnu.org/bugzilla/show_bug.cgi?id9121 joe.carnuccio at qlogic dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |joe.carnuccio at qlogic dot com --- Comment #4 from joe.carnuccio at qlogic dot com --- I have found the following: This works: c ^= d ^= c ^= d (where c and d are not pointers) This fails: *a ^= *b ^= *a ^= *b (where a and b are pointers) When compiling using -Os then the failed case now works.
next reply other threads:[~2015-06-25 18:20 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-25 18:20 thiago at kde dot org [this message] 2021-11-10 10:26 ` [Bug c++/66671] " pinskia at gcc dot gnu.org 2022-11-29 6:38 ` herring at lanl dot gov
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-66671-4@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).