[Bug c++/93614] New: C++ compile error with struct in template class and < operator

thilo.voertler@coseda-tech.com gcc-bugzilla@gcc.gnu.org
Thu Feb 6 15:12:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93614

            Bug ID: 93614
           Summary: C++ compile error with struct in template class and <
                    operator
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thilo.voertler@coseda-tech.com
  Target Milestone: ---

The following code does not compile. which I consider a compiler bug:

template<class T>
class foo{};

template<class T>
class template_class_with_struct
{
    void my_method() {
        if(this->b.foo < 1);
    };

    struct bar
    {
        long foo;
    } b;
};

It returns the following error message is returned:

 error: type/value mismatch at argument 1 in template parameter list for
'template<class T> class foo'

    8 |         if(this->b.foo < 1);

      |                          ^

The creation of template class foo leads to this error, it can be worked around
by writing b.bar::foo or parenthesis ((this->b.foo) < 1)  in the error line,
however it should not be neccessary. 

Note: MSVC accepts this this code without complaining


More information about the Gcc-bugs mailing list