Hacker News new | past | comments | ask | show | jobs | submit login

Make it an error unless all parameters passed are destructor-free (because there is non like int/pointer, or because they were passed in by reference)



That doesn't help, the parameter might be invalidated by a destructor (e.g. passing foo.c_str(), where foo is a std::string on the stack)


Then it isn't destructor-free (and not passed by reference if it's on the stack).


No. Arguments that are trivial types can still depend on other objects not being destroyed.

  void foo(const char* str) {
    if (*str == '\0') return;
    printf("%c", str[0]);
    std::string x = str + 1;
    return foo(x.c_str());
  }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: