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++/45964] New: The compiler does not complain about a required template keyword.


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

           Summary: The compiler does not complain about a required
                    template keyword.
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mschulze@ivs.cs.ovgu.de


Between version 4.2 and 4.4 the compiler changed in a way that it does not
complain about a required template keyword. In the following example IMO the
template keyword is required (C++-standard 14.2 in paragraph 4 and 5).

template<int a>
struct A {
    template<int b>
    struct B {
        static const int value;
      private:
        struct C {
            enum {value=10};
        };
    };

};
template<int a>
template<int b>
const int A< a>::B<b>::template value = A<a>::B<b>::C::value;

Since gcc 4.4 the code is accepted as it is. Older compilers reject it with the
error message "tp.cc:15: error: â::Câ has not been declared"

If I change the last code line to

const int A< a>::B<b>::template value = A<a>::template B<b>::C::value;

which is in my understanding the correct one, then the older compiler is also
satisfied. What drives me crazy, is that the new compiler works with this line
too. However, if I interpret the standard correct, the template keyword is not
optional here because "C" depends on a template parameter, and therewith the
template keyword is required.


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