Saturday, October 08, 2005

const/volatile integrity violation

This time I am going to point you at two short, interesting articles on const integrity violation which is also applicable to volatile modifier.

Basically it talks about the following feature of C++:

GIVEN
int *i;

const int *p = i; // is allowed
BUT
const int** p = &i; // is not allowed !!
AND
const int*& p = i; // is also not allowed !!

How to fix it?

GIVEN
int *i;

const int *p = i; // is allowed
BUT
const int* const * p = &i; // is allowed !!
AND
const int* const & p = i; // is also allowed !!


FAQ:
http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17
AND
http://www.gimpel.com/html/bugs/bug1561.htm

3 comments:

stunned said...

Astonshing blog. I relished in the site and you
know I will be going to it again! Surfing the internet
hepls me to find blogs that arfe just as good.
Check out the blog site with my coupon 1800contacts in it!

Smoker Affordable Term Life Insurance said...

Exciting blog. Your site was amazing and will be
back again! I never get tired of looking for blogs
just like this one.
Come as you are and look at my coupon 1800contacts blog.

after-while said...

Striking blog. I liked the site I will be back
again! Websurfing is a good way to find blogs like
yours.
In my spare time I will look for your coupon 1800contacts blog.