segmentation error with -fast option

Hi everyone,

I have a segmentation error appearing with a code compiled with -the -fast option, but the execution is going well when the code is compiled with -C, -O or even no option. Can someone help me understand why? I’m new in the forum and I haven’t seen this before.

Many thanks in advance

Hi mellore,

When an application encounters a segmentation violation at higher optimization but not lower optimization it’s typically caused by the compiler performing some transformation. This transformation may be incorrect (i.e. a compiler error), correct but not appropriate for your application, or correct but a programing error is exposed when the transformation is applied.

“-fast” is an aggregate flag composed of " -O2 -Munroll=c:1 -Mnoframe -Mlre -Mautoinline -Mvect=sse -Mscalarsse -Mcache_align -Mflushz -Mpre -Msmart" with slight variations between platforms. You can try starting at “-O2” (same as -O) and begin adding optimizations until the segv occurs. This will give you the what but not why.

To determine why, add the “-gopt” flag to create a binary with optimized debug information enabled. Next, run your program within the PGI debugger, “pgdbg”. The program should abort at location of the segv. Note debugging optimized code can be difficult since code can be rearranged due to optimizations.

If you’re really daring, you can add “-Mkeepasm -Manno” to keep the assembly file and compile with and without the offending optimization. Diffing the two assembly files will show what optimization occurred.

If this is a bit much and the application isn’t too big, feel free to send a report to PGI Customer Service ( and ask them to forward the code to me.

Hope this helps,