Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7842
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: removing constness of a true const |
| Date | 2011-07-16 08:36 +1200 |
| Message-ID | <98bmo4FdjcU1@mid.individual.net> (permalink) |
| References | (2 earlier) <ce8312c9-10ef-46d5-a2bc-0c267526dbd3@a11g2000yqm.googlegroups.com> <ivnivf$a1l$1@dont-email.me> <ivntgo$4eq$1@news.ett.com.ua> <ivpb50$grt$1@dont-email.me> <ivpofc$tdu$1@news.ett.com.ua> |
On 07/16/11 04:04 AM, Balog Pal wrote: > "Victor Bazarov"<v.bazarov@comcast.invalid> >>> const std::pair<int, int> foo = std::make_pair(1,2); >>> >>> is any less const than two separate ints? Or that overwriting them is >>> less UB? >>> >>> I'd be very disappointed if today's compilers would not put that pair in >>> the 'const' segment and fiddling with it would not cause a crash. >> >> Any data initializing which requires code to be executed at runtime cannot >> be put in "the 'const' segment" - the segment would not be const, would >> it? > > Why should it be initialized "at runtime"? Unless you have volatiles > involved, what is pretty rare, the standard mandates that initialisation > happened before you use. Not telling how much before. It can be done at > compile time, if the compiler can guess the result. Like in the above case. Maybe it could, but do you know a case where it is? The two compilers I tried (Sun CC and g++) build the object in a static constructor. Oh the joys of UB.... -- Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
removing constness of a true const siddhu <siddharth.sng@gmail.com> - 2011-07-14 08:07 -0700
Re: removing constness of a true const Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-14 11:55 -0400
Re: removing constness of a true const siddhu <siddharth.sng@gmail.com> - 2011-07-14 09:25 -0700
Re: removing constness of a true const Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-14 16:18 -0400
Re: removing constness of a true const "Balog Pal" <pasa@lib.hu> - 2011-07-15 01:18 +0200
Re: removing constness of a true const Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-15 08:17 -0400
Re: removing constness of a true const "Balog Pal" <pasa@lib.hu> - 2011-07-15 18:04 +0200
Re: removing constness of a true const Ian Collins <ian-news@hotmail.com> - 2011-07-16 08:36 +1200
Re: removing constness of a true const "Balog Pal" <pasa@lib.hu> - 2011-07-16 02:00 +0200
Re: removing constness of a true const Paavo Helde <myfirstname@osa.pri.ee> - 2011-07-15 16:08 -0500
Re: removing constness of a true const Ian Collins <ian-news@hotmail.com> - 2011-07-16 09:30 +1200
Re: removing constness of a true const "Balog Pal" <pasa@lib.hu> - 2011-07-14 19:05 +0200
Re: removing constness of a true const siddhu <siddharth.sng@gmail.com> - 2011-07-14 12:05 -0700
Re: removing constness of a true const "Bo Persson" <bop@gmb.dk> - 2011-07-14 23:33 +0200
Re: removing constness of a true const Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-14 17:46 -0400
Re: removing constness of a true const "Bo Persson" <bop@gmb.dk> - 2011-07-16 08:32 +0200
Re: removing constness of a true const "Johannes Schaub (litb)" <schaub.johannes@googlemail.com> - 2011-07-15 15:02 +0200
Re: removing constness of a true const Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-15 09:54 -0400
csiph-web