[cfe-commits] r148874 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/Analysis/reference.cpp

David Blaikie dblaikie at gmail.com
Sun Jan 29 00:15:08 PST 2012


On Sat, Jan 28, 2012 at 11:15 PM, John McCall <rjmccall at apple.com> wrote:
> On Jan 28, 2012, at 10:38 PM, Nico Weber wrote:
>> On Sat, Jan 28, 2012 at 4:50 PM, Chandler Carruth <chandlerc at google.com> 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
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list