[llvm-dev] Strange local variable cv::VideoCapture allocated

Adrian Tong via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 10 09:53:13 PDT 2019


On Sun, 9 Jun 2019 at 02:02, Tim Northover <t.p.northover at gmail.com> wrote:

> Hi Adrian,
>
> This question would probably be better in cfe-dev since it's about
> Clang and the C++ AST rather than anything LLVM, but I'll do my
> best...
>
> On Sun, 9 Jun 2019 at 03:47, Adrian Tong via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > I am using clang-6 to compile this C++ code and I see a strange
> temporary variable allocated at expression address 0x7ff1131536e8.
>
> There are several temporaries in that code, and that address
> represents none of them (or all, if you prefer).
>
> The easiest one to explain is from the most deeply nested at
> 0x7ff113153200. It's because the conditional operator is an
> expression, which means it has to produce a value with a single,
> well-specified type. In this case the LHS (read call) wants to be a
> bool and the RHS wants to be a cv::VideoCapture.
>
> According to C++ rules that bool can be implicitly converted to a
> cv::VideoCapture via one of its constructors (which takes an int). So
> cv::VideoCapture is chosen as the final type and Clang materializes
> temporaries to produce a value with that type. That's probably not
> what you want.
>
> I'm afraid I don't know about the outer temporaries. Definitely one for
> cfe-dev.
>
> Cheers.
>
> Tim.
>

Got it. Thank you Tim. This is what I need. I will send future questions
like this to cfe-dev.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190610/b4f9354d/attachment.html>


More information about the llvm-dev mailing list