Skip to content

[clang-cl] MSVC /options:strict is not supported (recognized as /o ptions:strict) #92911

Open
@MisterDA

Description

@MisterDA

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-cl`clang-cl` driver. Don't use for other compiler parts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions