Namespaces
Variants
Actions

Talk:c/language/lifetime

From cppreference.com

[edit] Temporary lifetime

From C99 to C11, wasn't there an extension to the lifetime of temporary objects? http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1285.htm This extension led to n1570:6.2.4/8. C99 said "do not modify" and "do not access" or risk undefined behavior; C11 says "do not modify" or risk undefined behavior. If so, is the line in the example "double d = g1(f().a); // OK, d is 3.15" UB in C99? Newatthis (talk) 04:41, 9 February 2016 (PST)

good catch. Yes, this was a defect in C99 that broke valid C89 code, which was fixed (at the april 2008 meeting) by adopting the C++ rule from this paper. Revboxed and noted in the example comments. --Cubbi (talk) 06:14, 9 February 2016 (PST)