Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: RValue Arra...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 9 Topic 9809 of 9909
Post > Topic >>

Re: RValue Arrays

by James Hopkin <tasjaevan@[EMAIL PROTECTED] > Jul 24, 2008 at 01:29 PM

On Jul 22, 1:10 am, Gabriel Dos Reis <g...@[EMAIL PROTECTED]
> wrote:
> David Abrahams <d...@[EMAIL PROTECTED]
> writes:
> |
> | Now
> |          X()
> |
> | is an rvalue of type X and
> |
> |          X().a
> |
> | would be an rvalue array... if I'm not mistaken, that is ;-)
>
> Yes, that is correct.  A disturbing point is that all components of that
> rvalue array are lvalues!  This defect was inherited from C90 which
> did not appreciate the existence of rvalue arrays.
>

According to Comeau's online compiler, in C89 an expression accessing
a component of an rvalue array *is* itself an rvalue. Not in C++, as
you say.

Here's the code I put through the online compiler (compiles in C99 and
C++, not in C89):

   typedef struct
   {
     int a[10];
   } X;

   X MakeX();

   void test()
   {
     int* p = &MakeX().a[3];
   }


James


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 9 Posts in Topic:
RValue Arrays
rkldabs@[EMAIL PROTECTED]  2008-07-20 18:33:40 
Re: RValue Arrays
David Abrahams <dave@[  2008-07-21 05:24:08 
Re: RValue Arrays
Oncaphillis <oncaphill  2008-07-21 14:41:13 
Re: RValue Arrays
Maxim Yegorushkin <max  2008-07-21 16:16:33 
Re: RValue Arrays
Gabriel Dos Reis <gdr@  2008-07-21 18:10:45 
Re: RValue Arrays
"Ivan A. Kosarev&quo  2008-07-23 07:28:14 
Re: RValue Arrays
"Ivan A. Kosarev&quo  2008-07-23 19:23:21 
Re: RValue Arrays
Gabriel Dos Reis <gdr@  2008-07-23 23:47:55 
Re: RValue Arrays
James Hopkin <tasjaeva  2008-07-24 13:29:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 4:06:07 CDT 2008.