It gets worse. Look at the following code:

using System;

class Class1
{
  static void Main(string[] args)
  {
    ArgIterator iter = new ArgIterator(Foo(__arglist(1, 2, 3)));
  }
  static RuntimeArgumentHandle Foo(__arglist)
  {
    return __arglist;
  }
} 

This is effectively the same as returning an ArgIterator, yet the C#
compiler does allow this variant.

Regards,
Jeroen

> 
> -----Original Message-----
> From: Frans Bouma [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 17, 2003 11:53
> To: [EMAIL PROTECTED]
> 
> > It's hardcoded in the compiler. If you've got the Rotor 
> > sources installed, the check is done in 
> TYPESYM::isSpecialByRefType().
> > http://dotnet.di.unipi.it/Content/sscli/docs/doxygen/csharp/sy
> mmgr_8cpp-
> source.html#l02546
> 
>         Hmmm. I really wonder why they didn't simply add an 
> attribute to
> the method. Hardcoding this kind of stuff is dangerous, it can be a
> source for bugs or other nasties in the future while it is completely
> unnecessary.
> 
>         FB
> 
> 
> Regards,
> Jeroen
> 
> > 
> > -----Original Message-----
> > From: Frans Bouma [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, June 17, 2003 10:20
> > To: [EMAIL PROTECTED]
> > 
> > > I wrote:
> > > 
> > > > I would guess that it has not so much to do with
> > ArgIterator being a
> > > > special type, but that in this instance, iterator 
> itself is stack 
> > > > allocated.  Frankly, I don't think this requires
> > documentation.  We
> > > > all know that you can't return a stack allocated struct from a
> > > > function.
> > > > Fortunately, we now have a compiler that won't let us do this
> > > > accidentally.
> > > 
> > > This was a foolish thing to post.  I hit send before thinking
> > > too deeply about it. Of course the boxing operation should 
> > > copy the struct to the heap. Sorry.
> > 
> >         Well, the assumption was not that weird. If you 
> check out the 
> > MSIL of ArgIterator, there is no special attribute attached to it. 
> > Which makes me wonder, why does the compiler generate an error on
> > this object?
> > Is that object hardcoded in the compiler or is there a 
> > special attribute
> > attached to it that isn't visible in the MSIL? (so you can use that
> > yourself in your code too)
> > 
> >         FB
> > 
> 

Reply via email to