Open
Description
Using solely -WX
to turn warnings as errors isn't sufficient to probe MSVC for unknown options. MSVC exits with a warning but not an error if it doesn't recognize an option. Following the bug report D9002 : ignoring unknown option
will not return an exit code on failure, /options:strict
was added in Visual Studio 2022 version 17.0 Preview 4.
clang-cl doesn't need it and mistakenly considers it as the output to a file option -o ptions:strict
.
> cl -nologo -WX -empanadas test.c
cl : Command line warning D9002 : ignoring unknown option '-empanadas'
test.c
> cl -nologo -options:strict -empanadas test.c
cl : Command line error D8043 : unknown option '-empanadas'
> clang-cl -WX -empanadas -c test.c
clang-cl: error: unknown argument ignored in clang-cl: '-empanadas' [-Werror,-Wunknown-argument]
> clang-cl -options:strict -c test.c
error: unable to rename temporary 'ptions:strict-3e22c2cd.obj.tmp' to output file 'ptions:strict.obj':
'invalid argument'
1 error generated.
I think it should be special cased, to not be recognized as -o <file>
.
There could be a case in clang-cl for -WX
to not activate warning-as-errors for unknown options to mimic MSVC, but IMO that was a design flaw of MSVC in the first place.