DIP 36: Rvalue References
Timon Gehr
timon.gehr at gmx.ch
Tue Apr 23 01:25:17 PDT 2013
On 04/23/2013 10:16 AM, Dicebot wrote:
> On Wednesday, 10 April 2013 at 07:39:25 UTC, Zach the Mystic wrote:
>> ...
>
> Kind of. I am thinking that scope is best when transitive for
> aggregation but not for indirection:
>
> struct S { int a; int *b; }
>
> void foo(scope S s)
> {
> static int *x1 = &(s.a); // error
> static int *x2 = s.b; // fine
> }
(Both of these are in error because static variables are initialized at
compile time, but I get what you mean.)
Why would 'scope' have any effect on the validity of the first? s.a
belongs to the callee exclusively. Adding modular annotations to prevent
taking its address has no point.
More information about the Digitalmars-d
mailing list