Possible case for a warning in the compiler?

Possible case for a warning in the compiler?

Hello everyone,

While I was making several changes in my code, I came across a case when using pragmas, that I managed to reduce to the following very simple testcase, contained in the file phitest.c:

#include <stdio.h>

int main()
        int     i, a = 0;

#if 0
#pragma offload target(mic) inout(a) \
#pragma offload target(mic) inout(a)
#pragma omp parallel for
        for (i = 0; i < 100000000; i++) {
                #pragma omp atomic

        printf("a = %d\n", a);


I compile the code using icc 14.0.2 with:

icc -O3 -fopenmp -o phitest phitest.c

Notice the backslash at the end of the first pragma. This program compiles without a problem, but it executes on the CPU. Technically speaking, this is the correct behavior. With the backslash, the "#else" goes with the previous line, so the two offload pragmas are actually inside the "#if 0". Of course, if I delete the backslash the program behaves as expected.

However, it took me several hours to find this error. The offload pragmas in my case were very long and the backslash was not visible until I scrolled to the end of the line. Maybe a lesson for me to turn on line breaking in my editor :-) Although I still haven't found a good way to parallelize my application for the Phi, this made me scratch my head for hours trying to figure out why the code is not executed on the Phi at all.

You think some warning message would be appropriate in this case or not? What is your opinion?

Ioannis E. Venetis

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

>>...You think some warning message would be appropriate in this case or not? What is your opinion?

When creating a single-line macro(s) there is a very simple rule: do not use the backslash at the end.

I agree that a warning message, or a remark, could help a developer to catch such cases.

The compiler did what you asked it to do.

I think though the compile should have an option -Lint to perform a "Lint" operation to catch questionable statements.

Jim Dempsey


I tried gcc -Wall but I do not get any warning,

>>>>I compile the code using icc 14.0.2 with:
>>>>icc -O3 -fopenmp -o phitest phitest.c
>>I tried gcc -Wall but I do not get any warning

Did you try command line options from the 1st post?

I agree with Om don't get any warning with GCC as well as with ICC as it executed what's asked for (valid code!)

%gcc --version
%gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
%gcc -O3 -fopenmp -o phitest phitest.c

I agree, it would be good if compiler can catch questionable syntax and issue a warning/remark depending on the context.


Hi Ioannis, 

I"ve filed this issue as a feature request with the developers to see if any warning/remark can be output in such a context and will keep you updated accordingly


Dear all,

Thank you for taking the time to investigate this. I appreciate it and I hope that the development team will come up with a nice solution.

Best regards,


Hi Ioannis,

Well, I heard back from the developers that for the compiler to issue a remark it needs to know the exact intent on which to issue a remark. That is, about the user's code that makes it likely to be unintentional than intentional. Additionally, adding a backslash without realizing it is a common mistake for users. That said, the issue I filed was closed as not a defect and not possible to add a remark for code that's perfectly valid. Let me know if you need any further clarifications. Appreciate your patience through this.

Leave a Comment

Please sign in to add a comment. Not a member? Join today