public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21165] New: bogus error on a user-defined conversion in a template
@ 2005-04-22 21:12 sebor at roguewave dot com
  2005-04-23  4:19 ` [Bug c++/21165] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: sebor at roguewave dot com @ 2005-04-22 21:12 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-05-31 18:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-22 21:12 [Bug c++/21165] New: bogus error on a user-defined conversion in a template sebor at roguewave dot com
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

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).