boostorg / boostorg/function

switch missing default label warning under clang

Open
#56 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
26
Forks
58
PR merge metrics
No merged PRs in 30d

Description

When compiling under clang 19.1.7 with werror and a number of other flags (we run with most warnings enabled), the line https://github.com/boostorg/function/blob/develop/include/boost/function/function_base.hpp#L147 is flagged with `error: switch missing default label [-Werror,-Wswitch-default]`. Given this is based on the enum at https://github.com/boostorg/function/blob/f6b538dbed2e3047dcbd09eb3f5c7f1ffa90d0a9/include/boost/function/function_base.hpp#L105 and all cases are handled a pr has not been provided at this time. I see two approaches, one is doing a compiler warning suppression and the other is adding the default label with a throw or similar as it should be an unreachable place based on the current code. The suppression seems like the simpler answer but may cause a future update to the enum to be missed here while the throw would prevent that at the cost of potentially changing behavior if something is flagged nothrow. Happy to submit a PR but would need guidance no how it should be approached here.

Env:
Alma 9.6
Boost 1.88.0 via cmake
clang 19.1.7

Contributor guide

No contributing guide indexed for this repository

Research direction

Read include/boost/function/function_base.hpp around the enum at line 105 and the switch at line 147, then reproduce the warning with clang 19.1.7 and the reported warning flags. Check the project guidance before choosing between suppression and a default case, and consider the issue done when the reported -Wswitch-default error no longer occurs without unintended behavior changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.