79469131

Date: 2025-02-26 09:20:28
Score: 1
Natty:
Report link

Threads have their own stack, but implementing a thread-local heap is difficult. The compiler does not know how much to allocate on the stack for the string. You could put it on the top of the stack and increase the stack pointer when initialising, but what if you have two strings? Furthermore, std::string is a datatype defined in the standard library, not the compiler, so its ability to reason about it is limited. I think it is sensible for a compiler to reject this code.

Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Single line (0.5):
  • Low reputation (0.5):
Posted by: asdfldsfdfjjfddjf