There is a “Command-line Conflicting Options” section in the reference manual, which reads:
Some options have an opposite or negated counterpart. For example, both -Mvect and -Mnovect are available. -Mvect enables vectorization and -Mnovect disables it. If you used both of these commands on a command line, they would conflict.
Note: Rule: When you use conflicting options on a command line, the last encountered option takes precedence over any previous one.
Brent’s been looking into what can be done. We think we can modify our configuration (rc) files to get this to work the way you’d like, but we’ll know for sure once an engineer is able to dig into it further. I’ve added problem report TPR #27806 to track.
In the meantime, there’s not much you can do except not include “-O2”, but Brent let me know that it gets implicitly added by your build system so may not be easy to remove.
Thanks a lot for looking into this. Let me put it into context. There is one source file in one external library our group is using that always segfaults when compiled with “-O2” or above. The user usually sets a universal optimization flag in CFLAGS, e.g. “-fast”. This flag works fine for all but that one file. Therefore, in the Makefile, we append “-O1” to CFLAGS for that specific file, hoping that “-O1” would override “-O2” “-O3” “-O4” or “-fast”.
Unfortunately, the code also segfaults with “-O2 -Mnovect”. Since the code in question was not written by us, nobody wants to touch it. What I could do is using something like “filter-out” to remove “-O2” and above from CFLAGS.