This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16128] New: poor diagnostic


template<typename T>
struct A {
    };

namespace H {
    template<typename T>
    struct B {};
    };

A a;
H::B b;

int main() {
    A a;
    H::B b;
    return 0;
    }


produces:

~/ootbc/common/test/src$ g++ foo.cc
foo.cc:10: error: `A' does not name a type
foo.cc:11: error: expected constructor, destructor, or type conversion before "b"
foo.cc:11: error: expected `,' or `;' before "b"
foo.cc: In function `int main()':
foo.cc:14: error: missing template arguments before "a"
foo.cc:14: error: expected `;' before "a"
foo.cc:15: error: missing template arguments before "b"
foo.cc:15: error: expected `;' before "b"

Oddly, the diagnostic produced when the error is inside a function is different from (and better than) that for the same error in file scope. And why the (bad) messages differ when the template is or is not namespace-qualified beats me.

Lastly, the missing ";" message seems redundant in all cases.

Ivan

p.s. Comeau gives:

Comeau C/C++ 4.3.3 (Aug  6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing.  All rights reserved.
MODE:strict errors C++

"ComeauTest.c", line 8: error: extra ";" ignored,
        In C: A function definition does not end with a semicolon
        In C++: A function definition, extern "C" or namespace, does not end with a semicolon
      };
       ^

"ComeauTest.c", line 10: error: argument list for class template "A" is missing
  A a;
  ^

"ComeauTest.c", line 11: error: argument list for class template "H::B" is missing
  H::B b;
  ^

"ComeauTest.c", line 14: error: argument list for class template "A" is missing
      A a;
      ^

"ComeauTest.c", line 15: error: argument list for class template "H::B" is missing
      H::B b;
      ^

"ComeauTest.c", line 15: error: expected a ";" (perhaps on the previous statement)
      H::B b;
           ^

"ComeauTest.c", line 14: warning: variable "a" was declared but never referenced
      A a;
        ^

6 errors detected in the compilation of "ComeauTest.c".

-- 
           Summary: poor diagnostic
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]