On Sat, Jan 28, 2012 at 11:15 PM, John McCall <[email protected]> wrote:
> On Jan 28, 2012, at 10:38 PM, Nico Weber wrote:
>> On Sat, Jan 28, 2012 at 4:50 PM, Chandler Carruth <[email protected]> 
>> wrote:
>>> qualifying the pointer with volatile works, and is only a touch awkward.
>>> We've already done this for one copy, I'll update the main open source
>>> version as soon as I'm able.
>>
>> You mean like
>>
>> template <typename T>
>> inline T Invalid() {
>>  return *static_cast<volatile typename remove_reference<T>::type*>(0);
>> }
>>
>> ? If I then pass a type with a default copy constructor (say "class A
>> {}; Invalid<A>();"), I get this error:
>
> Does this function need to have a body at all?  It seems like a
> metaprogramming function, and pure declarations generally suffice for those.

Yeah - in that case it's just C++11's "declval<T>" it seems.

> If it does need an actual body, it could just be "abort();" with no return
> statement.

Yeah - that sounds reasonable to me. (though I'm not the one who owns
the problematic code)

> Anything else requires you to have a way to actually produce
> a value of an arbitrary type from nothing, which is in general not
> possible.  Even your old method is vulnerable to types with inaccessible
> or deleted copy constructors.
>
> John.
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to