Reputation: 11
File "include/header.hpp"
#include <iostream>
class Eka
{
int x;
public:
Eka() { std::cout << x;};
Eka(int y) : x(y) {}
int Sqr() const { if(x > 5) return x + 1;};
};
file "eka.cpp"
#include <header.hpp>
int main() {
Eka e;
int x = e.Sqr();
int y {};
std::cin >> y;
std::cout << x + y;
return 0;
}
Build command:
g++ src.cpp -ores -Wall -Wextra -Werror -O1 -isystem include
Result:
g++11 hides warnings from "system" headers: compilation is successful
g++13.2 does not hide warnings: compilation failed. With "-O0" everything works fine.
What's the problem ?
I expect the same behavior from different compiler versions regardless of whether the optimization flag is present.
I expect that warnings from the "system" headers will be suppressed when optimization is enabled and the "isystem" flag is used.
Upvotes: 0
Views: 82