Skip to content

Commit

Permalink
Mark error_message in numeric_cast as unused
Browse files Browse the repository at this point in the history
In a release build without assertions or exceptions
enabled, `TSL_RH_THROW_OR_TERMINATE` is essentially a no-op
and we get a compiler warning that the error_message is unused:

```
In file included from .../robin-map/include/tsl/robin_map.h:34:
.../robin-map/include/tsl/robin_hash.h:77:35: warning: unused parameter 'error_message' [-Wunused-parameter]
                      const char* error_message = "numeric_cast() failed.") {
                                  ^
1 warning generated
```

Fix this by adding a `TSL_RH_UNUSED` for the error message here.
In C++17, the `[[maybe_unused]]` should be used instead.
  • Loading branch information
milianw authored and Tessil committed Sep 16, 2023
1 parent 851a59e commit 0430aee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/tsl/robin_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ static T numeric_cast(U value,
TSL_RH_THROW_OR_TERMINATE(std::runtime_error, error_message);
}

TSL_RH_UNUSED(error_message)

return ret;
}

Expand Down

0 comments on commit 0430aee

Please sign in to comment.