public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sebor at roguewave dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/21165] New: bogus error on a user-defined conversion in a template
Date: Fri, 22 Apr 2005 21:12:00 -0000	[thread overview]
Message-ID: <20050422211216.21165.sebor@roguewave.com> (raw)

The test case below demonstrates two problems:

1) the line number in the error message points to an expression that involves
only two ints (i.e., no object of T::BI as the message claims).

2) the program is well formed and the error is a regression from previous
versions of the compiler.


$ cat t.cpp && gcc -c t.cpp
/*   1 */ struct A
/*   2 */ {
/*   3 */     A (int = 0);
/*   4 */     operator int () const;
/*   5 */ };
/*   6 */ 
/*   7 */ struct B
/*   8 */ {
/*   9 */     typedef int BI;
/*  10 */     typedef A   BA;
/*  11 */ 
/*  12 */ };
/*  13 */ 
/*  14 */ template <class, class T>
/*  15 */ struct C
/*  16 */ {
/*  17 */     typedef typename T::BA BA;
/*  18 */     typedef typename T::BI BI;
/*  19 */ 
/*  20 */     BA foo (BA ba) {
/*  21 */         const int i = BI (ba);
/*  22 */ 
/*  23 */         if (i < 0)
/*  24 */             return A ();
/*  25 */ 
/*  26 */         return A ();
/*  27 */     }
/*  28 */ };
/*  29 */ 
/*  30 */ template struct C<char, B>;
t.cpp: In member function 'typename T::BA C< <template-parameter-1-1>,
T>::foo(typename T::BA)':
t.cpp:23: error: 'typename T::BI' used where a 'int' was expected

-- 
           Summary: bogus error on a user-defined conversion in a template
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.9
  GCC host triplet: sparc-sun-solaris2.9
GCC target triplet: sparc-sun-solaris2.9


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21165


             reply	other threads:[~2005-04-22 21:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-22 21:12 sebor at roguewave dot com [this message]
2005-04-23  4:19 ` [Bug c++/21165] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-04-26 15:10 ` reichelt at gcc dot gnu dot org
2005-05-03 21:44 ` pinskia at gcc dot gnu dot org
2005-05-31 13:23 ` nathan at gcc dot gnu dot org
2005-05-31 17:46 ` cvs-commit at gcc dot gnu dot org
2005-05-31 18:01 ` nathan at gcc dot gnu dot org
2005-05-31 18:05 ` cvs-commit at gcc dot gnu dot org

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=20050422211216.21165.sebor@roguewave.com \
    --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: link
Be 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).