JoshuaOloton opened a new issue, #46233:
URL: https://github.com/apache/arrow/issues/46233
### Describe the bug, including details regarding any error messages,
version, and platform.
When building Arrow in Debug configuration with compilers that enforce
`-Wmissing-braces` (e.g., Clang with `-Werror`), the following error occurs:
```
C:\src\arrow\cpp\src\arrow\util\thread_pool.cc(174,39): error: suggest
braces around initialization of subobject [-Werror,-Wmissing-braces]
174 | state->task_queue.push(QueuedTask{std::move(task),
std::move(stop_token),
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| {
175 | std::move(stop_callback),
hints.priority,
| ~~~~~~~~~~~~~~~~~~~~~~~~
| }
1 error generated.
ninja: build stopped: subcommand failed.
```
The error occurs in `thread_pool.cc` where a `QueuedTask` is being
constructed, but the initialization of the nested Task member is missing
braces, causing the compiler to issue a `-Wmissing-braces` warning.
### Current Code
```
state->task_queue.push(QueuedTask{std::move(task), std::move(stop_token),
std::move(stop_callback),
hints.priority,
state_->spawned_tasks_count_++});
```
### Proposed Change
Wrap the first three parameters (which initialize the Task member) with an
extra pair of curly braces {}.
```
state->task_queue.push(QueuedTask{{std::move(task), std::move(stop_token),
std::move(stop_callback)},
hints.priority,
state_->spawned_tasks_count_++});
```
### Additional Information
The `QueuedTask` struct declaration:
```
struct QueuedTask {
Task task;
int32_t priority;
uint64_t spawn_index;
// Implement comparison so that std::priority_queue will pop the low
priorities more
// urgently.
bool operator<(const QueuedTask& other) const {
if (priority == other.priority) {
// Maintain execution order for tasks with the same priority. Its
preferable to keep
// the execution order of tasks deterministic.
return spawn_index > other.spawn_index;
}
return priority > other.priority;
}
};
```
### Environment
- Compiler: Clang
- Platform: Windows
- Build system: Ninja + CMake
### Component(s)
C++
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]