public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14965] New: Missing template keyword after scope operator leading to weird error, meybe even segfault
@ 2004-04-15 14:06 arno at mpi-sb dot mpg dot de
  2004-04-15 14:24 ` [Bug c++/14965] " arno at mpi-sb dot mpg dot de
  2004-04-15 14:42 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: arno at mpi-sb dot mpg dot de @ 2004-04-15 14:06 UTC (permalink / raw)
  To: gcc-bugs

The enclosed example program fails to be legal C++ because of a missing
'template' keyword after a scope operator ::. However, the error message
emitted by g++ 3.3.3 is completely wrong, and a similar mistake in a
program of several 10000 lines of code even causes an internal compiler
error (segmentation fault) which I could not reproduce in a short example.
I'm reporting the small example because I suspect that both problems are
effects of the same cause.

Thank you in advance.

Error message:
example.C: In member function `void Example<Type_traits>::f() [with Type_traits
   = Int_traits]':
example.C:37:   instantiated from here
example.C:30: error: no match for call to `(
   C<Int_traits>::Fortytwo_functor<int>) (C<int>&)'
example.C:7: error: candidates are: TArg2
   C<TArg1>::Fortytwo_functor<TArg2>::operator()(C<TArg1>) [with TArg2 = int,
   TArg1 = Int_traits]

(Notice that the template argument to C<> is reported wrongly every time.)

Complete source code:

template <class TArg1>
class C {
public:
    template <class TArg2>
    class Fortytwo_functor {
    public:
        TArg2 operator() (C) { return TArg2(42); }
    };
};

class Int_traits {
public:
    typedef int Chosen_type;
};

template <class Type_traits>
class Example {
public:
    typedef typename Type_traits::Chosen_type T;
    void f() {
        typedef C<T> My_C;
        My_C c;

// this version compiles correctly
//        typename My_C::template Fortytwo_functor<T> ftf;

// this version exposes the problem:
        typename My_C::Fortytwo_functor<T> ftf;

        int ft= ftf(c);
    }
};

int main(int, char**) {
    typedef Example<Int_traits> Example;
    Example ex;
    ex.f();
    return 0;
}

// EOF

Complete compiler argument and version information:

gcc-3.3.3 example.C -o example -lstdc++ -L/usr/local/gcc-3.3/gcc-3.3.3/lib
-Wl,-R/usr/local/gcc-3.3/gcc-3.3.3/lib -save-temps -v
Reading specs from
/usr/local/gcc-3.3/gcc-3.3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: ./configure --prefix=/usr/local/gcc-3.3/gcc-3.3.3
--program-suffix=-3.3.3 --enable-languages=c,c++ : (reconfigured) ./configure
--prefix=/usr/local/gcc-3.3/gcc-3.3.3 --program-suffix=-3.3.3
--enable-languages=c,c++ : (reconfigured) ./configure
--prefix=/usr/local/gcc-3.3/gcc-3.3.3 --program-suffix=-3.3.3
--enable-languages=c,c++
Thread model: posix
gcc version 3.3.3

-- 
           Summary: Missing template keyword after scope operator leading to
                    weird error, meybe even segfault
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: arno at mpi-sb dot mpg dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/14965] Missing template keyword after scope operator leading to weird error, meybe even segfault
  2004-04-15 14:06 [Bug c++/14965] New: Missing template keyword after scope operator leading to weird error, meybe even segfault arno at mpi-sb dot mpg dot de
@ 2004-04-15 14:24 ` arno at mpi-sb dot mpg dot de
  2004-04-15 14:42 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: arno at mpi-sb dot mpg dot de @ 2004-04-15 14:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From arno at mpi-sb dot mpg dot de  2004-04-15 13:22 -------
Created an attachment (id=6087)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6087&action=view)
Preprocessed source code (as requested by submission instructions)


-- 


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


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

* [Bug c++/14965] Missing template keyword after scope operator leading to weird error, meybe even segfault
  2004-04-15 14:06 [Bug c++/14965] New: Missing template keyword after scope operator leading to weird error, meybe even segfault arno at mpi-sb dot mpg dot de
  2004-04-15 14:24 ` [Bug c++/14965] " arno at mpi-sb dot mpg dot de
@ 2004-04-15 14:42 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-15 14:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-15 13:47 -------
3.4.0 and 3.5.0 give:
pr14965.cc: In member function `void Example<Type_traits>::f()':
pr14965.cc:28: error: non-template `Fortytwo_functor' used as template
pr14965.cc:28: error: (use `Example<Type_traits>::f()::My_C::template Fortytwo_functor' to indicate 
that it is a template)
pr14965.cc:28: error: declaration does not declare anything
pr14965.cc: In member function `void Example<Type_traits>::f() [with Type_traits = Int_traits]':
pr14965.cc:37:   instantiated from here
pr14965.cc:30: error: `ftf' was not declared in this scope

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.4.0


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


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

end of thread, other threads:[~2004-04-15 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-15 14:06 [Bug c++/14965] New: Missing template keyword after scope operator leading to weird error, meybe even segfault arno at mpi-sb dot mpg dot de
2004-04-15 14:24 ` [Bug c++/14965] " arno at mpi-sb dot mpg dot de
2004-04-15 14:42 ` pinskia 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).