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]

Re: Bug in g++ using -pedantic option.


Martin v. Loewis wrote:

> > template <class T> struct B: public A<T> {
> >   B(value v): v(v) {}  // Here starts the fun using -pedantic and FORCE_BUG!
> >   value v;
> > };
>
> This code is clearly in error. In standard C++, the base class of a
> class template is not implicitly searched at template definition
> time. Therefore, value is undefined and not a typename. Then
>
>    B(value v)
>
> is in error, and v has no type.

Implicit or not, it doesn't help to specify it explicit neither. This

    B(A<T>::value v)

is just as little helpful.


> As an extension, GNU C++ does support using names in base types even
> for template classes. With -pedantic, this extension is disabled.
>
> With egcs-2.93.21, you get the error even without FORCE_BUG.

It was quite a job to reverse engineer the problem and figure out that I needed a
second and implicit defined template parameter in the base class to make -pedantic
react, since this wasn't excactly obvious. If -pedantic is supposed to be
consistent, it should trap other choice of template parameters too, and I think
people aught to be aware of such a circumstance. If egcs-2.93.21 completely fixes
this inconsistency, the problem eventually will sease as people upgrade their
compiler. As far as it comes to the error message provided, I think it could be an
idea to make the error message a bit more informative and exact about what the
problem is. As is, it looks like the compiler is in trouble not knowing exactly
what it asserts, just that it gets in trouble.

- gb -


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