Opened 5 years ago

#13227 new Bugs

exception.hpp : disable false warning C4265 given by Visual Studio

Reported by: Pascal Thomet <pthomet@…> Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc:

Description

Hi,

MSVC falsely report a missing virtual destructor inside exception.hpp Would it be possible to add a "pragma warning (disable:4265)" in this file ? This will *not* happen with the default settings of Visual Studio : it happens when trying to raise the warning level (/we4265 : treat "misssing virtual destructor" as an error)

Steps to reproduce the problem :

  • Compile the following program:
    #include <string>
    #include <iostream>
    #include <boost/optional/optional.hpp>
    
    int main(int argc, char **argv)
    {
      boost::optional<std::string> name;
      if (argc > 1)
        name.reset(argv[1]);
    
      if (name.is_initialized())
        std::cout << "Hello, " << name.get() << "\n";
      else
        std::cout << "Hello, world \n";
      return 0;
    }
    
    
  • With the following command line :
      cl hello.cpp /Iboost_1_64_0 /EHa /W3 /we4265
    

outputs

c:\tmp>cl hello.cpp /Iboost_1_64_0 /EHa /W3 /we4265
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.
hello.cpp
boost_1_64_0\boost/exception/exception.hpp(176): error C4265: 'boost::exception_detail::error_info_container': class has virtual functions, but destructor is not virtual
         instances of this class may not be destructed correctly

For more details, please also refer to https://github.com/ivsgroup/boost_warnings_minimal_demo

The problem occurs with boost 1.64 and 1.62.

Thanks & regards !

Change History (0)

Note: See TracTickets for help on using tickets.