1

I've posted this original question, but since it isn't an issue related to CMake, I'm rephrasing it:

I've this example:

#include <iostream>
#include <string>

int main()
{
        std::string a("Text");

        std::cout << a.c_str() << std::endl;

        return 0;
}

which I'm trying to compile with ICC (icc (ICC) 19.1.1.217 20200306, tested using GCC 4.8, 7, 8 and 9 as base) using this line:

icc -o OUT -pedantic-errors -fmax-errors=1 -march=native -Wall -Werror -Wfatal-errors -Wextra -ftree-vectorize -g -Wl,--exclude-libs,ALL -O3 -DNDEBUG -fPIC -fvisibility=hidden -Wstrict-aliasing -std=gnu++17 main.cpp

But it triggers a warning that results in an error (because of -Werror). This is the output when using GCC 8 gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3) as the base compiler:

icc: warning #10193: -vec is default; use -x and -ax to configure vectorization
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h(5052) (col. 50): error #2102: violation of ansi-alias rules

compilation aborted for main.cpp (code 4)

So, in order to compile, I must remove the -Wstrict-aliasing check. And just like that, there's a whole set of other checks that triggers a similar behavior (warnings from system include files).

My concern is that I'd really like to have those checks in place for my own code, but obviously, not for libraries over which I've no control.

A suggestion was to use -isystem or -isystem=/opt/rh/devtoolset-8/root/usr/include/c++/8, but that only modifies the error:

icc: warning #10193: -vec is default; use -x and -ax to configure vectorization
/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'

And even CMake discourages explicitly the use of -isystem on system include files.

Any ideas of another flag that turns off those warnings for system include files?

Replacing icc by gcc (g++) fixes the issue.

Thanks for your help.

  • Why not do what the warning says? – Asteroids With Wings Jan 21 '21 at 14:41
  • If you are talking about the ```warning #10193```, removing ```-ftree-vectorize``` gets rid of it, but not of the main issue (the one that actually triggers the error). Or are you talking about the "ansi-alias" issue? What should I do? – Alvaro Palma Aste Jan 21 '21 at 14:57
  • *but that only modifies the error:* That's not a "modification", that's a completely different problem. You seem to be missing the implementation of `int main()`. Please share the contents of `main.cpp`, after minimizing them (remove everything that doesn't cause the error to disappear). – Kuba hasn't forgotten Monica Jan 21 '21 at 16:00

0 Answers0