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.

If it does need an actual body, it could just be "abort();" with no return
statement.  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

Reply via email to