Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68744

Warnings Next Generation can't parse long lines

XMLWordPrintable

      The msBuild (and possibly all parsers) can not detect issues if the line are long. I have not been able to determine the exact breaking point but it is around 4000 characters on a line.

      When using nested lambdas in C++, it is not uncommon for very long error/warning messages from visual studio compiler.

      Below are two example outputs.

      This example is not detected (4635 characters)

      C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\type_traits(1534,1): warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of dataC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(660): note: see reference to function template instantiation 'int std::invoke<_Callable&,_Ty,>(LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>&,_Ty1 &&) noexcept(false) with [_Callable=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>, _Ty=size_t, _Ty1=size_t]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(822): note: see reference to function template instantiation '_Rx std::_Invoker_ret<_Rx,false>::_Call<_Callable&,_Ty>(_Fx,_Ty &&) noexcept(false) with [_Rx=size_t, _Callable=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>, _Ty=size_t, _Fx=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886> &]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(822): note: see reference to function template instantiation '_Rx std::_Invoker_ret<_Rx,false>::_Call<_Callable&,_Ty>(_Fx,_Ty &&) noexcept(false) with [_Rx=size_t, _Callable=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>, _Ty=size_t, _Fx=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886> &]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(821): note: while compiling class template member function '_Rx std::_Func_impl_no_alloc<LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>,_Rx,size_t>::_Do_call(size_t &&) with [_Rx=size_t]'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(717): note: see reference to class template instantiation 'std::_Func_impl_no_alloc<LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>,_Ret,size_t> with [_Ret=size_t]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(911): note: see reference to variable template 'const bool _Is_large<std::_Func_impl_no_alloc<<lambda_186e8d783211d4718c75f80981d4d886>,unsigned __int64,unsigned __int64> >' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(1042): note: see reference to function template instantiation 'void std::_Func_class<_Ret,size_t>::_Reset<LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>>(_Fx &&) with [_Ret=size_t, _Fx=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(1042): note: see reference to function template instantiation 'void std::_Func_class<_Ret,size_t>::_Reset<LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>>(_Fx &&) with [_Ret=size_t, _Fx=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>]' being compiled..\symri\TriggerCompileWarning.cpp(53): note: see reference to function template instantiation 'std::function<size_t (size_t)>::function<LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>,0>(_Fx) with [_Fx=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>]' being compiled..\symri\TriggerCompileWarning.cpp(52): note: see reference to function template instantiation 'std::function<size_t (size_t)>::function<LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>,0>(_Fx) with [_Fx=LongTraceWarningInTraits::<lambda_1928bcd9221ebe214799fcab6696dc05>::()::<lambda_186e8d783211d4718c75f80981d4d886>]' being compiled
      

      This example is detected (3741 characters)

      C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\type_traits(1534,67): warning C4244: 'argument': conversion from '_Ty1 with [_Ty1=double]' to 'const float', possible loss of dataC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(660): note: see reference to function template instantiation 'float std::invoke<_Callable&,_Ty,>(WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>&,_Ty1 &&) noexcept(false) with [_Callable=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>, _Ty=double, _Ty1=double]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(822): note: see reference to function template instantiation '_Rx std::_Invoker_ret<_Rx,false>::_Call<_Callable&,_Ty>(_Fx,_Ty &&) noexcept(false) with [_Rx=double, _Callable=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>, _Ty=double, _Fx=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99> &]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(822): note: see reference to function template instantiation '_Rx std::_Invoker_ret<_Rx,false>::_Call<_Callable&,_Ty>(_Fx,_Ty &&) noexcept(false) with [_Rx=double, _Callable=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>, _Ty=double, _Fx=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99> &]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(821): note: while compiling class template member function '_Rx std::_Func_impl_no_alloc<WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>,_Rx,double>::_Do_call(double &&) with [_Rx=double]'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(717): note: see reference to class template instantiation 'std::_Func_impl_no_alloc<WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>,_Ret,double> with [_Ret=double]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(911): note: see reference to variable template 'const bool _Is_large<std::_Func_impl_no_alloc<<lambda_dcbbac96137333a65019a656a76a5e99>,double,double> >' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(1042): note: see reference to function template instantiation 'void std::_Func_class<_Ret,double>::_Reset<WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>>(_Fx &&) with [_Ret=double, _Fx=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>]' being compiledC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\functional(1042): note: see reference to function template instantiation 'void std::_Func_class<_Ret,double>::_Reset<WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>>(_Fx &&) with [_Ret=double, _Fx=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>]' being compiled..\symri\TriggerCompileWarning.cpp(40): note: see reference to function template instantiation 'std::function<double (double)>::function<WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>,0>(_Fx) with [_Fx=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>]' being compiled..\symri\TriggerCompileWarning.cpp(40): note: see reference to function template instantiation 'std::function<double (double)>::function<WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>,0>(_Fx) with [_Fx=WarningInTraits::<lambda_dcbbac96137333a65019a656a76a5e99>]' being compiled
       

      I tested to add the examples for the unit-test for the MS Build parser, and it gave with the same result (no match on first example). I'm assuming that some stream reader only buffers lines up to a certain length and then truncates them. I've also tested the regular expression for MS Build against the examples on regex101.com and in that case both examples matches against the regex. Hence my assumption of the lines being truncated in the plugin.

       

      Here is the example C++ code that generated the warning with visual studio compiler:

      #include <iostream>
      #include <stdexcept>
      #include <functional>
      
      static void WarningInTraits(){
          /**
           * Warning in Traits due to possible loss of data. */
          []( std::function<double( const double )> f ) {
              double d = 10.0;
              std::cout << f( d ) << std::endl;
          }( []( const float f ) { return f; } );
      }
      
      
      static void LongTraceWarningInTraits(){
          /** Nested lambdas to create very long error message.
           * See also WarningInTraits().
           * Jenkins might not be able to parse this, due to bug not parsing long lines. */
          []() {
              []( std::function<size_t( const size_t )> f ) {
                  size_t s = 10;
                  std::cout << f( s ) << std::endl;
              }( []( const int i ) { return i; } );
          }();
      }
      
      int main(){
          WarningInTraits();
          LongTraceWarningInTraits();
          return 0;
      }
      

            Unassigned Unassigned
            per_bohlin Per Böhlin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: