Home > OS >  Microsoft C/C : what is the definition of "strict conformance" w.r.t. implementation?
Microsoft C/C : what is the definition of "strict conformance" w.r.t. implementation?

Time:10-15

Context:

/Za, /Ze (Disable Language Extensions):

... the C compiler conforms strictly to the C89/C90 standard

/permissive- (Standards conformance):

... and sets the /Zc compiler options for strict conformance

C Conformance improvements, behavior changes, and bug fixes in Visual Studio 2019:

... /permissive may be specified to turn off strict conformance mode in the compiler.

The second option is meant to disable the strict conformance mode ...

clock:

Note that this is not strictly conformant with ISO C99 ...

Walkthrough: Compile a C program on the command line:

MSVC is compatible with the ANSI C89 and ISO C99 standards, but not strictly conforming.

Question: what is the definition of "strict conformance"? Was it invented by Microsoft?

Note: both C (n2596.pdf) and C (n4849.pdf) standards no not use term "strict conformance" / "strictly conforming" applied to the implementation. The implementation is either conforming, either non-conforming. W/o gradations.

UPD. My guess: under "strict conformance" (w.r.t. to implemtation) Microsoft means "conforming implementation w/o support of any extensions".

CodePudding user response:

A key part of your confusion is that /Za and /Ze are deprecated and haven't been updated in ages. It was introduced for ANSI 98 and hasn't changed since. Don't use those switches, and ignore any references to them in the docs.

The modern Visual C "conformance" switch is /permissive- and the various /Zc switches, in combination with /std.

The current "most conformant" options are:

  • C 20 is: /std:c 20
  • C 17 is: /std:c 17 /permissive- /Zc:preprocessor.
  • C 14 is: /std:c 14 /permissive- /Zc:preprocessor.
  • C11 is: /std:c11
  • C17 is: /std:c17

https://devblogs.microsoft.com/cppblog/msvc-cpp20-and-the-std-cpp20-switch/

A bit part of the conformance issues with Visual C is related to the preprocessor

https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/

https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/

For the feature-by-feature breakdown, see Microsoft Docs

CodePudding user response:

The C11 standard defines a strictly conforming program and implementation in section 4 paragraphs 5-7 as follows:

5 A strictly conforming program shall use only those features of the language and library specified in this International Standard. It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior, and shall not exceed any minimum implementation limit.

6 The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any strictly conforming program. A conforming freestanding implementation shall accept any strictly conforming program in which the ∗ use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and <stdnoreturn.h>. A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.

7 A conforming program is one that is acceptable to a conforming implementation.

While the terms strictly conforming implementation and strict conformance do not appear here, they can be understood to mean an implementation (in a given mode) that will only accept a strictly conforming program (or more accurately, an implementation that doesn't support features not specified in the standard) .

  • Related