================
@@ -9242,3 +9242,15 @@ Declares that a function potentially allocates heap 
memory, and prevents any pot
 of ``nonallocating`` by the compiler.
   }];
 }
+
+def ValueTypeDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+The ``value_type`` attribute can be used to mark user-defined types as 'value
+types'. When objects of value types are passed value to functions, the objects
+are always considered to be formally copied into a new object. This means the
+argument itself must be the only value referencing the passed object. This
----------------
rjmccall wrote:

Ugh, right, stack arguments.

Anyway, that code specifically has... at least *unspecified* behavior. 
`NonTrivial` satisfies the conditions of [class.temporary]p3, and so the 
compiler is permitted (but not required) to perform additional copies when 
passing and returning it, which makes it impossible to specify under the 
standard whether the object addresses compare the same. They do if all copies 
are avoided, they don't if the return copy is avoided but the parameter copy is 
not, and it's UB if there's a return copy because the pointer no longer points 
to allocated storage.

I don't know whether that's a strong enough argument to actually make it UB to 
have pointers to the parameter, though.

https://github.com/llvm/llvm-project/pull/95004
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to