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 support@ccsinfo.com

Dereferencing pointer, no compiler warning

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wileur



Joined: 29 Apr 2014
Posts: 2

View user's profile Send private message

Dereferencing pointer, no compiler warning
PostPosted: Tue Apr 29, 2014 7:23 am     Reply with quote

I'm using structs, and pointers to structs, and found that the compiler is not warning about the following case:

Code:

typedef struct TEST {
    uint8_t member;
} TEST;

TEST var;
TEST *pointer = &var;

var.member = 5;         // Correct
var->member = 5;        // Wrong, and compoler throws an error
pointer->member = 5;    // Correct
pointer.member = 5;     // Wrong, but no error


On other platforms I would be greeted by an error and quickly fix it. But here I get no message at all. Is it silently overlooked by the compiler (very serious) or is it accepted and somehow referenced correctly anyway (less serious, but confusing)?

The manual does list compiler error messages, but nothing about this. Google only led to this forum,... Searching here didn't produce anything either. Anyone that knows?

I'm using CCS PCD V1.435.
Ttelmah



Joined: 11 Mar 2010
Posts: 19350

View user's profile Send private message

PostPosted: Tue Apr 29, 2014 7:31 am     Reply with quote

It just puts the 5, directly into pointer.

It has been pointed out here many hundreds of times that the syntax checking in CCS is appalling. I syntax check using a different compiler, with a suite of special macros, so it doesn't throw a wobbly about the CCS constructs. Tools like lint are also commonly used.
It has slowly (too slowly) improved.

Report it to CCS.
wileur



Joined: 29 Apr 2014
Posts: 2

View user's profile Send private message

PostPosted: Wed Apr 30, 2014 7:02 am     Reply with quote

Thanks, I'll look at lint. What compiler do you use?

I'll report it to CCS though.
Ttelmah



Joined: 11 Mar 2010
Posts: 19350

View user's profile Send private message

PostPosted: Wed Apr 30, 2014 2:39 pm     Reply with quote

It's a commercial IBM one. I wrote part of it, so did my own custom 'core', and some syntax macros, that make it able to emulate the CCS compiler. Only problem is they keep changing things. Upgrading to make it work with V5, was an exercise....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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