Search code examples
c++eclipseideeclipse-cdt

Eclipse shows an error but gcc compiles fine


I have this MCVE:

#include <stdio.h>
#include <string>
#include <vector>

auto wrapperMain( const std::vector<std::string> & commandLineArguments ) -> void
{
    printf( "argc=%d\n", commandLineArguments.size() );
}

int main( int argc, char * argv [] )
{
    wrapperMain( { argv, argv + argc } );
//  ^^^^^^^^^^^^ <- Eclipse does not like this
}

It compiles fine with gcc 7.3 using the highest warning and pedantic options for C++17 [even it is not a C++17 feature].

Eclipse underlines wrapperMain and shows this error message:

Invalid arguments '
Candidates are:
void wrapperMain(const std::vector<std::__cxx11::basic_string
   <char,std::char_traits<char>,
   std::allocator<char>>,std::allocator<std::__cxx11::basic_string
   <char,std::char_traits<char>,
   std::allocator<char>>>> &)
'

I know I can disable this underlined error using the Eclipse @suppress directive:

wrapperMain( { argv, argv + argc } ); // @suppress("Invalid arguments")

but I would like to fix it in general.

My question: Is it a Eclipse bug or is a setting missing?


Solution

  • This is almost certainly a bug in Eclipse CDT. I filed bug 531322 to track.

    UPDATE: The bug has now been fixed.