jeudi 29 juin 2017

Clang returns different compiler errors for system include files

main.cpp:

#include "test.h"
void main () {narrowingConversion ();}

include/test.h:

void narrowingConversion () {int i = 1; char a[1] = {i};}

Clang compiles the above code successfuly when including the include folder as a system folder:

clang++ -std=c++0x -isystem./include main.cpp

But clang fails when the folder is included normally:

clang++ -std=c++0x -I./include main.cpp

./include/test.h:1:54: error: non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list [-Wc++11-narrowing]

Aucun commentaire:

Enregistrer un commentaire