[C++ dayly bug report] const_cast to rvalue of class type

Gabriel Dos_Reis Gabriel.Dos_Reis@sophia.inria.fr
Mon May 3 04:25:00 GMT 1999


Benjamin Scherrey <scherrey@switchco.com> writes:

| 	Yep, didn't notice the '&' there at first. I guess I can't disagree
| with your interpretation of the text. It does seem vauge in this area.

I find it quite clear. It unambiguously states what is permitted, how
the syntaxe should read and the semantics. Also that is not *my*
interpretation. This issue was raised up by Guillaume Laurent in
news:fr.comp.lang.c++ and diserved lengthy discussion involving James
Kanze. I should confess that at the fisrt place I thought the program
was well-formed until I read the relevant section of the Standard --
which is extremely clear. 

| ... I
| wonder why they didn't explicitly mention a limitation of only
| const_cast'ing pointers and references like they did for dynamic_cast if
| that was their intent.

They do by giving a detailled list of what is allowed and stating
explicitly:

---
  ... Conversions that can be performed explicitly using const_cast
  are listed below. No other conversion shall be performed explicitly
  using const_cast.
---

| ...  I still don't believe that it was their intent to
| limit the const_cast as you say at all. 

Can you give evidence to support your claims? Did you read 5.2.11/12?

| ... Can you tell me why this
| limitation would be meaningful? I don't see anything gained by it.

That is an interesting question. I wasn't yet on the committee when
the decision was made and can't report what were the pros. Anyway, you 
can still ask in comp.std.c++.

-- Gaby


More information about the Gcc-bugs mailing list