public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Jens.Maurer@gmx.net To: gcc-gnats@gcc.gnu.org Subject: c++/6451: function template argument deduction wrong Date: Thu, 25 Apr 2002 07:26:00 -0000 [thread overview] Message-ID: <20020425141805.8047.qmail@sources.redhat.com> (raw) >Number: 6451 >Category: c++ >Synopsis: function template argument deduction wrong >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Apr 25 07:26:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jens Maurer >Release: 3.0.4 and 3.2 20020423 (experimental) >Organization: >Environment: Linux 2.4.17 >Description: The attached program gives errors with gcc 3.0.4, although according to ISO C++ section 14.8.2p2, only type deduction should fail, so the other overload should be taken. [...] template-deduct-fail-datamember.cc: In instantiation of `has_int_data_x<X1>': template-deduct-fail-datamember.cc:38: instantiated from here template-deduct-fail-datamember.cc:17: invalid use of undefined type `struct has_int_data_x<X1>' template-deduct-fail-datamember.cc:8: forward declaration of `struct has_int_data_x<X1>' [...] It even produces an internal error with 3.2 20020423 (as a regression from 3.0.4): Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. jmaurer@gigue:~/C++/ISO/Curacao/htdocs/demo > /opt/exp/gcc/bin/g++ template-deduct-fail-datamember.cc >How-To-Repeat: #include <iostream> struct small_t { int m[1]; }; struct large_t { int m[20]; }; // find if a class has a data member (of a given type) template<class T> struct has_int_data_x { private: template<class U> struct helper { template<int U::*> struct inner { }; }; template<class U> static small_t check(typename helper<U>::template inner<&U::x>*); template<class U> static large_t check(...); public: static const bool value = sizeof(check<T>(0)) == sizeof(small_t); }; template<class T> const bool has_int_data_x<T>::value; struct X1 { int x; }; struct X2 { double x; }; struct X3 { int y; }; int main() { std::cout << has_int_data_x<X1>::value << has_int_data_x<X2>::value << has_int_data_x<X3>::value << std::endl; return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-04-25 14:26 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-25 7:26 Jens.Maurer [this message] 2002-05-20 12:16 Jens Maurer 2002-09-15 5:07 nathan 2002-10-26 2:12 lerdsuwa 2003-01-23 1:30 bangerth
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=20020425141805.8047.qmail@sources.redhat.com \ --to=jens.maurer@gmx.net \ --cc=gcc-gnats@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).