Skip to content

Suppress MSVC warnings 4582 and 4583 #47

@haphi

Description

@haphi

MSVC (v142) issues the warning 4582 ("constructor is not implicitly called") on tl::detail::optional_storage_base<T,true> , like so:

optional\include\tl/optional.hpp(385,1): warning C4582: 'tl::detail::optional_storage_base<T,true>::m_value': constructor is not implicitly called [...]
          with [ T=std::pair<int,double> ]
optional\include\tl/optional.hpp(384): message : while compiling class template member function 'tl::detail::optional_storage_base<T,true>::optional_storage_base(void) noexcept' [...]
          with [ T=std::pair<int,double> ]

The compiler is right: the constructor of the m_value field of the m_dummy union is not called. But this is intentional, so the warning is not useful and could be suppressed.

Similarly, the warning 4583 (destructor not explicitly called) is issued on tl::detail::optional_storage_base<T,false>:

optional\include\tl/optional.hpp(366,1): warning C4583: 'tl::detail::optional_storage_base<T,false>::m_value': destructor is not implicitly called [...]
          with [ T=`anonymous-namespace'::TestClass ]
optional\include\tl/optional.hpp(366): message : while compiling class template member function 'tl::detail::optional_storage_base<T,false>::~optional_storage_base(void)' [...]
          with [ T=`anonymous-namespace'::TestClass ]

One solution to suppress this is to wrap

#pragma warning( push )
#pragma warning( disable: 4582 4583 )
[...]
#pragma warning( pop )

around the code. I'll open a corresponding merge request for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions