CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problem with version 4.140
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Fri Jun 28, 2013 1:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 28, 2013 10:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 28, 2013 11:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 28, 2013 12:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 01, 2013 7:52 am     Reply with quote

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;
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group