Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Defeating Optimisation for memcmp()
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Martin, post: 3148196"] I think my example was wrong. Of course memcpy() is being passed a pointer to a volatile char. This is more what I meant: char arr[10]; char arr2[10] volatile char *parr = arr; /* ... code that initialises both arrays ... */ if ( memcmp(&parr[3], &arr2[3], 1) ... ) /* etc. */ Which is analagous to Chris Torek's use of the volatile pointer to structure. I think that is OK because the first argument now is not pointing to a volatile once deferenced, but the parr itself it volatile so the call to memcmp() cannot be optimised away - *however* in the case above where one element of an array is being compared with another, I can see that my original example in tandem with the use of the != operator you suggest is a solution I can adopt. Thanks for your help. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Defeating Optimisation for memcmp()
Top