beast icon indicating copy to clipboard operation
beast copied to clipboard

MSVC warning about unused variable

Open oxygene opened this issue 4 years ago • 4 comments

I'm getting a warning from MSVC about unreferenced formal parameter in boost 1.75.0 here:

https://github.com/boostorg/beast/blob/855fc23885307aeb6ad1318001a4bbdd4345d47c/include/boost/beast/websocket/impl/ssl.hpp#L65

oxygene avatar Jan 25 '21 07:01 oxygene

Great, thanks for letting me know.

madmongo1 avatar Jan 25 '21 07:01 madmongo1

Was not able to reproduce this warning with the following setup and using /Wall on boost 1.75.0 (x64):

Visual Studio 16 2019 Windows SDK version 10.0.18362.0 to target Windows 10.0.19042 MSVC 19.28.29335.0

@oxygene could you provide further information about your setup?

KnoerleMan avatar Feb 21 '21 11:02 KnoerleMan

That's interesting, as /Wall is supposed to Displays all warnings displayed by /W4 and all other warnings that /W4 doesn't include—for example, warnings that are off by default. as per documentation.

We are using MSVC2017 with default /W3 warning level, but selectively pull in other warnings like /w34100 (https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4100) which is the one I mentioned in this issue.

The code line mentioned in my first post undoubtedly declares bytes_transferred but does not use it anywhere. Unfortunately, I don't understand the code base good enough to tell whether the second parameter is needed to satisfy some concept or interface, but I've seen boost::ignore_unused(bytes_transferred) being used in other places and maybe this is the solution here as well?

oxygene avatar Feb 22 '21 07:02 oxygene

just leave out the parameter name if it is unused

vinniefalco avatar Feb 22 '21 17:02 vinniefalco

Closing this as the fix seems to be merged.

klemens-morgenstern avatar Sep 24 '22 05:09 klemens-morgenstern