Compiler fails to issue an error for incorrect template instantiation, when instantiated from within a different template that is legal

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Not Prioritized

      The attached file has these lines ...

          // Both of these should see error diagnostics, but only the second
          // one does
          Test::Compile_template<32>::a;
          Test::Compile_time<32 <= 1>::value;
      

      Here is how Compile_time is implemented ...

          template<bool b>
          struct Compile_time;
      
          template<>
          struct Compile_time<true>
          {
              static const uint16_t value = 0;
          };
      
          // Because no specialization for Compile_time<false> is supplied,
          // any instantiation with a <false> input should result in a
          // compile time error.
      

      Build it ...

      % cl2000 --verbose_diagnostics file.cpp
      "file.cpp", line 22: error: incomplete type is not allowed
               static const bool b = Compile_time<32 <= 1>::value;
                                     ^
      
      "file.cpp", line 30: warning: expression has no effect
            Test::Compile_template<32>::a;
            ^
      
      "file.cpp", line 31: error: incomplete type is not allowed
            Test::Compile_time<32 <= 1>::value;
            ^
      
      "file.cpp", line 34: warning: expression has no effect
            Test::Compile_template<1>::a;
            ^
      
      "file.cpp", line 35: warning: expression has no effect
            Test::Compile_time<0 <= 1>::value;
            ^
      
      2 errors detected in the compilation of "file.cpp".
      
      >> Compilation failure
      

      Ignore the warnings about expression has no effect. That's expected. The two errors issued are also expected. The problem is line 30 gets no error. It should, because it instantiates Compile_template with the value <32>, which in turn instantiates Compile_time with the expression <32 <= 1>.

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Connection: Intermediate to External PROD System
                EXTSYNC-3558 - Compiler fails to issue an error fo...
                SYNCHRONIZED
                • Last Sync Date: