A temporary object is destroyed when the full-expression that lexically contains the rvalue whose evaluation created that temporary object is completely evaluated. Let me demonstrate with ASCII art:
____________________ full-expression ranges from 'b' to last ')'
bar( foo().c_str() );
^^^^^ ^
| |
birth funeral