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++/29633] New: syntax error in do/while condition with templates reports incorrect line number


The simplest way to explain this is with an example.  When compiling the
testcase below, g++ will report an error on lines 16, but it should report an
error on lines 18.  If you change just about anything about this example, it
will report the correct line number (e.g. using non-template classes for either
class, changing the pointer type to Class1<int>, removing "tc_a &&" from the
condition).  So there's some interaction between a template member function
referencing the name/pointer of a templated class in a logic expression in a
do/while loop that is causing the wrong line number to be reported.  It's
definitely an obscure situation, but it left me scratching my head for a while
trying to figure out why my code wouldn't compile.

template <typename T>
struct Class1
{
  void testfn1(void);
};

template <typename T>
class Class2
{
public:
  void testfn2(void)
  {
    Class1<T> * tc_a;
    do
    {
      int x = 0; //line 16
    }
    while (tc_a && tc_a->testfn1); //line 18
  }
};

int main(void)
{
  Class2<int> tc2;
  tc2.testfn2();
  return 0;
}


-- 
           Summary: syntax error in do/while condition with templates
                    reports incorrect line number
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ceckak at alumni dot washington dot edu
  GCC host triplet: g++ (GCC) 4.1.1 20060724 (prerelease) (4.1.1-3mdk)


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


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