Compiler Bug???

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Compiler Bug???

跳至解决方案
3,164 次查看
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


 
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,619 次查看
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 项奖励
回复
5 回复数
1,619 次查看
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 项奖励
回复
1,619 次查看
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 项奖励
回复
1,619 次查看
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 项奖励
回复
1,619 次查看
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 项奖励
回复
1,620 次查看
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 项奖励
回复