Compiler Bug???

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Compiler Bug???

Jump to solution
3,163 Views
electropw
Contributor III
Hi all,
 
Am using the latest version of CW for the HCS12.
 
When defining a macro does the compiler ignore the "\" command that tells it the code continues on the next line.
 
Let me explain. In the following macro
 
#define OSEnterCritical()               do {  __asm PSHC;    \
                                                                __asm SEI;        \
                                                               DiHook();            \
                                                        } while (0)
 
the second and third lines are ignored when compiling.
 
If you put those lines on the same line as the first all is ok.
 
#define OSEnterCritical()               do {  __asm PSHC;  __asm SEI;  DiHook();  \
                                                        } while (0)
 
 
The strange thing is that if you take a C file that uses the macro and you right click and perform a
preprocess of the file it produces the same output for either method.
If you instead generate a disassembly file only the later method works.
 
No errors or warnings are generated.
 
Anybody seen this or know what I'm doing wrong?
 
regards
Phil


 
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,618 Views
electropw
Contributor III
Hi All,
 
Support came back to me and it looks like we have an answer.
 
We had to turn off the "branch tail optimization".
 
I'm not sure why this effected my code, however it worked and I'm happy for now.
 
Phil
 

View solution in original post

0 Kudos
Reply
5 Replies
1,618 Views
CompilerGuru
NXP Employee
NXP Employee
Can you attach a complete source file showing the issue? If it is really a bug,
can you please submit  a service request, so it gets fixed.
One thing with line continuations to check for is that there is no space/tab after the slash. If there is one the slash only escapes the space and does not actually mean a line continuation.

Daniel
0 Kudos
Reply
1,618 Views
electropw
Contributor III
Hi Daniel,
 
It is an iffy bug and not always repeatable.
 
I have contacted support. They responded with some test code for me to test and it did not fail.
 
So I have returned them my project showing the problem and what I have found during my own testing.
 
Am currently waiting their response.
 
Hopefully it is just me :smileyhappy:
 
Phil
 
 
0 Kudos
Reply
1,618 Views
CompilerGuru
NXP Employee
NXP Employee
>not always repeatable.
Does that mean the compiler does not always generate the same code?
Usually the runtime behavior is not repeatable, but the compiler is generating the same code, so I wonder what is the nature of this issue, is it that at runtime the two instructions are skipped, or that the compiler is not emitting them?

Daniel
0 Kudos
Reply
1,618 Views
electropw
Contributor III
What I mean is, that by changing the code the compiler can suddenly compile correctly or dfferently.
 
In my case the macro
 
#define OSEnterCritical()    do { __asm PSHC; \
                                                    __asm SEI; \
                                                    OSDiHook();\
                                              } while(0) 
 compiled to
 
    PSHC
change the macro to
 
#define OSEnterCritical()    do { __asm PSHC; \
                                                    OSDiHook();\
                                                    __asm SEI; \
                                             } while(0) 
 
compiles to
 
    PSHC
    call     OSDiHook()
    SEI
 
OR change the macro to
 
#define OSEnterCritical()    do { __asm PSHC; \
                                                    __asm SEI; \
                                                    __asm SEI; \
                                                    OSDiHook();\
                                              } while(0) 
 
compiles to
 
    PSHC
    SEI
 
Phil
 
0 Kudos
Reply
1,619 Views
electropw
Contributor III
Hi All,
 
Support came back to me and it looks like we have an answer.
 
We had to turn off the "branch tail optimization".
 
I'm not sure why this effected my code, however it worked and I'm happy for now.
 
Phil
 
0 Kudos
Reply