Search code examples
c++aixxlc

xlC warning, "The NOSTRICT option has the potential to alter the semantics of a program"


I'm testing on the GCC Compile Farm and GCC119. GCC119 is a AIX machine with the xlC 13.1 compiler. I know very little about the platform and compiler.

When I build under xlC:

$ CXX=xlC gmake CXXFLAGS="-DNDEBUG -g2 -O3 -qrtti" -j 8
xlC -DNDEBUG -g2 -O3 -qrtti -c cryptlib.cpp
xlC -DNDEBUG -g2 -O3 -qrtti -c cpu.cpp
...
xlC -DNDEBUG -g2 -O3 -qrtti -c hmac.cpp
1500-036: (I) The NOSTRICT option (default at OPT(3)) has the potential to alter the 
semantics of a program.  Please refer to documentation on the STRICT/NOSTRICT option
for more information.
...

The IBM manual for the compiler is located at Compiler Reference v13.1. It does not mention STRICT or NOSTRICT. The closest it comes based on a keyword search is a discussion of __C99_RESTRICT when -qkeyword=restrict is in effect. Additionally, there are no man pages:

$ man NOSTRICT
Manual entry for NOSTRICT not found or not installed.
$ man 3 NOSTRICT
There is not an entry for NOSTRICT in section 3.
$ man STRICT
Manual entry for STRICT not found or not installed.
$ man 3 STRICT
There is not an entry for STRICT in section 3.
$ man OPT
Manual entry for OPT not found or not installed.
$ man 3 OPT
There is not an entry for OPT in section 3.

When I compile with -qflag=w the warnings go away, so I have even less information to work with. (The library and program compiles cleanly with -qflag=w).

I have two questions. First, what exactly is xlC complaining about? Second, is there an option to have xlC tell me the source file and line number it is complaining about?


Solution

  • If you look for info about the -qstrict and -qnostrict options, you should find it here in HTML format, or on page 349 (if you're going by page numbers), or page 367 (if you're using the PDF page advancer) in PDF format.

    Since you're using -O3 (OPT(3)), as the message says, by default the -qnostrict option is in effect, which means that compared to if you compiled with -qstrict, more aggressive optimizations are performed to create a faster executable at a cost of having slight semantic differences in your program. Look at the documentation (copied below) to read about what that means specifically; if any of the differences mentioned below are important to you, compile with -O3 -qstrict to prevent these semantic differences from occurring, but your application performance may not be as good.

    With -qnostrict in effect, the following optimizations are turned on:

    • Code that may cause an exception may be rearranged. The corresponding exception might happen at a different point in execution or might not occur at all. (The compiler still tries to minimize such situations.)
    • Floating-point operations may not preserve the sign of a zero value. (To make certain that this sign is preserved, you also need to specify -qfloat=rrm, -qfloat=nomaf, or -qfloat=strictnmaf.)
    • Floating-point expressions may be reassociated. For example, (2.0*3.1)4.2 might become 2.0(3.1*4.2) if that is faster, even though the result might not be identical.
    • The fltint and rsqrt suboptions of the -qfloat option are turned on. You can turn them off again by also using the -qstrict option or the nofltint and norsqrt suboptions of -qfloat. With lower-level or no optimization specified, these suboptions are turned off by default.

    Your man commands will not work as written as NOSTRICT, STRICT, and OPT are compiler options and cannot be used with man. In order to view the compiler man pages, you need to use man xlC.

    There is no source file and line number information associated with this info message because it is a general message to you across all files compiled with -O3.

    If you'd like to give feedback on the documentation (including man pages, online docs etc), IBM is looking for feedback.

    P.S. The full documentation for IBM XL C/C++ for AIX, V13.1 can be found in HTML format or PDF format. There are several "books" that make up the full compiler documentation, including the compiler reference.