| View previous topic :: View next topic |
| Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 20161
|
|
Posted: Fri Jun 28, 2013 1:05 am |
|
|
That is a very good point.
What Fvm is thinking about, is that the optimiser _will_ remove something that is never used. So if you declare a variable and never reference it at all, the space will be claimed back. There will be a warning that the variable is never used. This would explain the bit assignment.
Best Wishes |
|
 |
Max
Joined: 15 Dec 2003 Posts: 51 Location: Italy
|
|
Posted: Fri Jun 28, 2013 10:26 am |
|
|
We haven't any warning about Variable never used
| Code: | Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FH "ct01.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA #__18F458=TRUE
>>> Warning 201 "ct01.c" Line 541(1,1): Assignment inside relational expression
>>> Warning 208 "ct01.c" Line 1053(1,8): Function not void and does not return a value EXT_isr
>>> Warning 201 "ct01.c" Line 1332(1,1): Assignment inside relational expression
>>> Warning 201 "ct01.c" Line 1342(1,1): Assignment inside relational expression
>>> Warning 203 "ct01.c" Line 1383(1,1): Condition always TRUE
>>> Warning 203 "ct01.c" Line 2039(1,1): Condition always TRUE
>>> Warning 201 "ct01.c" Line 2286(1,1): Assignment inside relational expression
>>> Warning 201 "ct01.c" Line 2293(1,1): Assignment inside relational expression
>>> Warning 201 "ct01.c" Line 3138(1,1): Assignment inside relational expression
>>> Warning 203 "ct01.c" Line 3545(1,1): Condition always TRUE
>>> Warning 207 "ct01.c" Line 4004(29,30): Code has no effect
Memory usage: ROM=79% RAM=72% - 79%
0 Errors, 11 Warnings.
Build Successful.
|
I observe that :
in debug mode the bit state it's ok ,
but when the program read the in_data[].contact the result it's wrong
because the assembler generated as you check on line 0844 test the wrong bit!
We also tested the code on CCS rel. 4.129 it's all ok!
we get a problem only with rel. 4.140 |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20161
|
|
Posted: Fri Jun 28, 2013 11:20 am |
|
|
Some there you should fix.
Declare your EXT_isr handler as void.
What is the code at line 4004. You have something there that is doing nothing, but you probably think it does.
The assignment inside relational expression, suggests you may be using '=' for a comparison, where you should be using '=='. Code won't then have a hope of doing what it should....
Best Wishes |
|
 |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Jun 28, 2013 12:23 pm |
|
|
| Quote: | | What Fvm is thinking about, is that the optimiser _will_ remove something that is never used. |
Yes, that's one thinkable explanation. In this case, the result should depend on the utilization of other
structure bits which can be detected. I doubt if optimizing variable storage this way should be considered
an acceptable compiler action.
But that's something we may discuss if the assumption can be verified. The other explanation would be
that it's just a purposeless artefact, taking place if a certain code or data size is exceeded. Such things
happened before. |
|
 |
Max
Joined: 15 Dec 2003 Posts: 51 Location: Italy
|
|
Posted: Mon Jul 01, 2013 7:52 am |
|
|
The warning "Assignment inside relational expression "
occurs because an assignment to do 'internal relational expression "while"
while ((c = s[i]) != ('\0')) but the code works fine.
| Code: | unsigned int16 ascii_to_int16(char *s, unsigned int16 max)
{
unsigned int32 n;
int8 i;
char c;
i = 0;
while ((c = s[i]) != ('\0'))
{
if ((c < '0') || (c > '9') || (i > 4)) //
{
return 0;
}
i++;
}
n = atoi32(s);
if (n > max)
n = max;
return (int16) n;
} |
|
|
 |
|