public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gcc_bugzilla at friedman dot to" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/26148] New: g++ bug, possibly introduced around gcc 3.4.0 Date: Tue, 07 Feb 2006 02:14:00 -0000 [thread overview] Message-ID: <bug-26148-12147@http.gcc.gnu.org/bugzilla/> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 5085 bytes --] In the transcript below, the program "problem.C", which does not include any header files, shows a bug in gcc 3.4.0 under Linux (kernel version 2.6.11) running on an Intel Pentium 4, which still exists in gcc 4.0.2 but does not exist in gcc 3.3.2. I also enclose two slightly modified versions of "problem.C", called "ok1.C" and "ok2.C", which both pass under the newer compilers. I have a very large software system in C++ which does not compile on the latest compiler, and I spent a long time trying to reduce the code to this small example which I enclose below in "problem.C". Unfortunately, the two workarounds "ok1.C" and "ok2.C" are not an option in my large system, and any real workaround would involve either a significant design change or a major kludge, both of which I would rather avoid, so until I hear from you I cannot migrate my system over to the latest compiler. Please help! Sincerely, Joseph Friedman, Ph.D. Millennium Partners, L.P. 666 Fifth Avenue, 8th Floor New York, NY 10103 (212) 841-4160 ------------------------------------------------------------------------ % /usr/local/gcc-3.3.2/bin/g++ -v Reading specs from /usr/local/gcc-3.3.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs Configured with: ./configure --prefix=/usr/local/gcc-3.3.2 Thread model: posix gcc version 3.3.2 % /usr/local/gcc-3.4.0/bin/g++ -v Reading specs from /apps/local.linux/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/specs Configured with: ./configure --prefix=/usr/local/gcc-3.4.0 Thread model: posix gcc version 3.4.0 % /usr/local/gcc-4.0.2/bin/g++ -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --prefix=/usr/local/gcc-4.0.2 Thread model: posix gcc version 4.0.2 % /usr/local/gcc-3.3.2/bin/g++ ok1.C % /usr/local/gcc-3.3.2/bin/g++ ok2.C % /usr/local/gcc-3.3.2/bin/g++ problem.C % /usr/local/gcc-3.4.0/bin/g++ ok1.C % /usr/local/gcc-3.4.0/bin/g++ ok2.C % /usr/local/gcc-3.4.0/bin/g++ problem.C problem.C: In constructor `s1<T>::s1(const T&) [with T = pair<double, double>]': problem.C:35: instantiated from here problem.C:14: error: cannot convert `const pair<double, double>' to `double' for argument `1' to `void ns1::f(double)' % /usr/local/gcc-4.0.2/bin/g++ ok1.C % /usr/local/gcc-4.0.2/bin/g++ ok2.C % /usr/local/gcc-4.0.2/bin/g++ problem.C problem.C: In constructor s1<T>::s1(const T&) [with T = pair<double, double>]: problem.C:35: instantiated from here problem.C:14: error: cannot convert const pair<double, double> to double for argument 1 to void ns1::f(double) % cat problem.C template<class T1, class T2> struct pair { pair(T1 x, T2 y) : first(x) {} T1 first; T2 second; }; template<class T1, class T2> pair<T1, T2> make_pair(T1 x, T2 y) { return pair<T1, T2>(x, y); } namespace ns1 { void f(double x) {} } template<class T> struct s1 { T a; int i; s1(const T& x) : a(x) { ns1::f(x); } }; namespace ns1 { template<class T> bool f(const pair<T, T>& x) { f(x.first); } } template<class T> struct s2 { typedef pair<T, T> pair_type; }; template <class S> struct s3 : public S { typedef s1<typename S::pair_type> t3; }; int main() { pair<double, double> p = make_pair((double)5, (double)12); s3< s2<double> >::t3 o = s3< s2<double> >::t3(p); return 0; } % cat ok1.C template<class T1, class T2> struct pair { pair(T1 x, T2 y) : first(x) {} T1 first; T2 second; }; template<class T1, class T2> pair<T1, T2> make_pair(T1 x, T2 y) { return pair<T1, T2>(x, y); } namespace ns1 { void f(double x) {} } namespace ns1 { template<class T> bool f(const pair<T, T>& x) { f(x.first); } } template<class T> struct s1 { T a; int i; s1(const T& x) : a(x) { ns1::f(x); } }; template<class T> struct s2 { typedef pair<T, T> pair_type; }; template <class S> struct s3 : public S { typedef s1<typename S::pair_type> t3; }; int main() { pair<double, double> p = make_pair((double)5, (double)12); s3< s2<double> >::t3 o = s3< s2<double> >::t3(p); return 0; } % cat ok2.C template<class T1, class T2> struct pair { pair(T1 x, T2 y) : first(x) {} T1 first; T2 second; }; template<class T1, class T2> pair<T1, T2> make_pair(T1 x, T2 y) { return pair<T1, T2>(x, y); } void f(double x) {} template<class T> struct s1 { T a; int i; s1(const T& x) : a(x) { f(x); } }; template<class T> bool f(const pair<T, T>& x) { f(x.first); } template<class T> struct s2 { typedef pair<T, T> pair_type; }; template <class S> struct s3 : public S { typedef s1<typename S::pair_type> t3; }; int main() { pair<double, double> p = make_pair((double)5, (double)12); s3< s2<double> >::t3 o = s3< s2<double> >::t3(p); return 0; } -- Summary: g++ bug, possibly introduced around gcc 3.4.0 Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc_bugzilla at friedman dot to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26148
next reply other threads:[~2006-02-07 2:14 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-02-07 2:14 gcc_bugzilla at friedman dot to [this message] 2006-02-07 2:24 ` [Bug c++/26148] " pinskia at gcc dot gnu dot org 2006-02-08 17:41 ` gcc_bugzilla at friedman dot to 2006-02-08 17:44 ` pinskia at gcc dot gnu dot org 2006-02-08 22:30 ` gdr at integrable-solutions dot net
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-26148-12147@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).