[cfe-dev] Is this a bug or just illegal code
Joerg Sonnenberger via cfe-dev
cfe-dev at lists.llvm.org
Thu Jun 8 11:16:51 PDT 2017
On Thu, Jun 08, 2017 at 11:05:37AM -0700, don hinton via cfe-dev wrote:
> I'm seeing memory corruption when I use a literal string and std::string in
> a ternary (?:) expression. If I change ss to ss.c_str() on line 5, the
> corruption goes away. [1] is an AST diff, which might help explain it.
I would expect that you are getting a temporary string object and gets
destroyed immediately, so Ref points to garbage. The AST seems to agree
with that.
Joerg
More information about the cfe-dev
mailing list