cl compiler should honor /WX and/or /weCODE for command line argument warnings - by andrew.c.morrow

Status : 

  Deferred<br /><br />
		The product team has reviewed this issue and has deferred it for consideration at a later time.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
1
Sign in
to vote
ID 781052 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/9/2013 11:55:27 AM
Access Restriction Public

Description



Currently, passing unknown flags to the cl compiler results in a warning. Here we pass a flag that doesn't exist, /GLEFBG:


C:\>cl /c ./foo.cc /GLEFBG
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '/GEFBG'
foo.cc


That is all well and good. However, I'd like unknown flags to be an error, for two reasons:

- I may require that a flag be available. If it is not, I want to fail the build.
- I want to run a script that determines if a flag is available with the current compiler. However, if the use of a non-supported flag causes a warning, rather than an error, then the compiler exits with an OK error status, so I can't detect that the flag was not found.


The obvious approach of passing /WX doesn't work:


C:\>cl /c ./foo.cc /WX /GLEFBG

Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '/GEFBG'
foo.cc


So even though we have asked for warnings to be errors, our unknown flag still elicits only a warning.

Attempting to explicitly enable that warning as an error doesn't work either:


C:\>cl /c ./foo.cc /WX /weD9002 /GLEFBG
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line error D8021 : invalid numeric argument '/weD9002'


So it appears that there is no way to convince cl to treat unknown flags as errors and therefore set a non-zero exit status when one is provided on the command line.

The compiler should make it possible to escalate unknown flag arguments to errors.

Please see the following two links for additional context:


http://stackoverflow.com/questions/15259720/how-can-i-make-the-microsoft-c-compiler-treat-unknown-flags-as-errors-rather-t


http://stackoverflow.com/questions/15274521/using-scons-trycompile-to-examine-compiler-flag-support-on-windows
Sign in to post a comment.
Posted by andrew.c.morrow on 9/18/2013 at 12:47 PM
I've once again found myself in need of a command line script that can detect the availability of an option, and, once again, I'm stymied by cl.exe's arbitrary refusal to honor the semantics of /WX when applied to warning D9002, rendering it impossible to evaluate the exit status of a cl.exe invocation to detect support for a switch.

Please reconsider your decision not to fix this.


Posted by andrew.c.morrow on 4/30/2013 at 8:06 AM
Well, that is rather disappointing. Good thing the clang folks are working so hard on native Windows support.
Posted by Microsoft on 4/30/2013 at 5:03 AM
Hi Andrew,

Thank you for taking the time to provide your feedback. After reviewing your reported issue, in the context of all the issues reported to us, we have decided not to take any action on this feedback at this time. We will re-consider our decision for a future release.

If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance.
For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.

Thanks,
Karl Niu
VC++ Team
Posted by Microsoft on 3/21/2013 at 11:17 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 3/9/2013 at 12:53 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by andrew.c.morrow on 3/9/2013 at 11:56 AM
Apologies about the formatting. I have no idea why none of my formatting was retained: when I wrote this, it was broken into paragraphs...