Hi,
The following code compiles fine with g++ (GCC) 7.3.0, but in Eclipse (Eclipse IDE for C/C++ Developers (includes Incubating components) Version: 2021-12 (4.22.0) Build id: 20211202-1639) I get errors from the code analyzer.
In Eclipse I set this up as a c++ linux project, and I set the C++ compiler "dialect" to ISO C++17.
Build command:
make all
Building file: ../src/a.cpp
Invoking: GCC C++ Compiler
g++ -std=c++17 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/a.d" -MT"src/a.o" -o "src/a.o" "../src/a.cpp"
Finished building: ../src/a.cpp
Building target: a
Invoking: GCC C++ Linker
g++ -o "a" ./src/a.o
Finished building target: a
File b.h:
#include <tuple>
typedef int I;
struct S {
int m;
};
std::tuple<I const, S const , int const > getTuple();
std::tuple<I const, S const > get2Tuple();
std::tuple<S const , int const > get3Tuple();
File a.cpp:
#include "b.h"
#include <iostream>
int main() {
{
auto [first, second, third] = getTuple();
std::cout << first << std::endl; // /a/src line 7: std::endl is underlined in red by code analyzer
std::cout << second.m << std::endl;
std::cout << third << std::endl;
}
{
auto [first, second] = get2Tuple();
std::cout << first << std::endl; // /a/src line 13: std::endl is underlined in red by code analyzer
std::cout << second.m << std::endl;
}
{
auto [second, third] = get3Tuple();
std::cout << second.m << std::endl; // /a/src line 18: m and std::endl is underlined in red by code analyzer
std::cout << third << std::endl;
}
return 0;
}
std::tuple<I const, S const , int const > getTuple()
{
I first = 1;
S second;
second.m = 2;
int third = 3;
return std::tuple<I const, S const , int const >(first, second, third);
}
std::tuple<I const, S const> get2Tuple()
{
I first = 1;
S second;
second.m = 2;
return std::tuple<I const, S const>(first, second);
}
std::tuple<S const , int const > get3Tuple()
{
S second;
second.m = 2;
int third = 3;
return std::tuple<S const , int const >(second, third);
}
These are the errors I get - and rebuilding the index does not fix it:
Invalid overload of 'std::endl' a.cpp /a/src line 7 Semantic Error
Invalid overload of 'std::endl' a.cpp /a/src line 13 Semantic Error
Field 'm' could not be resolved a.cpp /a/src line 18 Semantic Error
Invalid overload of 'std::endl' a.cpp /a/src line 18 Semantic Error
Is this a bug in Eclipse, or do I configure something incorrectly.