Opened 8 years ago
Last modified 7 years ago
#10149 new Bugs
boost::optional<T> can be constructed from a typed in place factory of the wrong type
Reported by: | Owned by: | Fernando Cacciola | |
---|---|---|---|
Milestone: | To Be Determined | Component: | optional |
Version: | Boost 1.49.0 | Severity: | Problem |
Keywords: | Cc: |
Description
For example:
boost::optional<char> oa = boost::in_place<double>(0); type-checks but results in runtime undefined behavior, placement new of double in a buffer of size char.
Note:
See TracTickets
for help on using tickets.
Can you provide a short but complete example that demonstrates the problem?
I can see that the following code does not even compile on GCC and Clang (which is desirable).