You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@arrow.apache.org by Caleb Epstein <ca...@gmail.com> on 2018/10/09 00:07:13 UTC

Row-Wise Tutorial: UB?

Re: https://arrow.apache.org/docs/cpp/md_tutorials_row_wise_conversion.html

The example code suggests you do the following (eliding some lines for
brevity):

std::unique_ptr<DoubleBuilder> components_values_builder(new
DoubleBuilder(pool));
ListBuilder components_builder(pool, std::move(components_values_builder));

But then:

for (const data_row& row : rows) {
[...]
ARROW_RETURN_NOT_OK(components_values_builder->Append(
row.cost_components.data(), row.cost_components.size(),
nullptr);
}



Given that components_values_builder has been moved-from above, won't this
be UB, likely crashing your app? Is there a more correct way to write this?

Re: Row-Wise Tutorial: UB?

Posted by Wes McKinney <we...@gmail.com>.
hi Caleb -- this tutorial has fallen out of date. The child builder in
0.10 and 0.11 is now a shared_ptr
https://github.com/apache/arrow/blob/master/cpp/src/arrow/builder.h#L798

I'm opening an issue to fix the tutorial -- such is the peril of
tutorials that we don't compile
https://issues.apache.org/jira/browse/ARROW-3470

thanks
Wes
On Mon, Oct 8, 2018 at 8:07 PM Caleb Epstein <ca...@gmail.com> wrote:
>
> Re: https://arrow.apache.org/docs/cpp/md_tutorials_row_wise_conversion.html
>
> The example code suggests you do the following (eliding some lines for brevity):
>
> std::unique_ptr<DoubleBuilder> components_values_builder(new DoubleBuilder(pool));
> ListBuilder components_builder(pool, std::move(components_values_builder));
>
> But then:
>
> for (const data_row& row : rows) {
> [...]
> ARROW_RETURN_NOT_OK(components_values_builder->Append(
> row.cost_components.data(), row.cost_components.size(),
> nullptr);
> }
>
>
>
> Given that components_values_builder has been moved-from above, won't this be UB, likely crashing your app? Is there a more correct way to write this?