kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.62k stars 248 forks source link

std::is_pov deprecated - Visual Studio #190

Closed dpieve closed 8 months ago

dpieve commented 9 months ago

On Visual Studio 2022, this code works if Platform toolset = LLVM (clang-cl):

kfr::univector<f32, 134> taps;
const kfr::expression_handle<f32> window = kfr::to_handle<kfr::expression_kaiser<f32>>(kfr::window_kaiser<f32>(taps.size()));

If Platform toolset = Visual Studio 2022 (v143), it gives an error:

1>E:\kfr\include\kfr\cometa.hpp(196,42): error C4996: 'std::is_pod_v<cometa::f32>': was declared deprecated

The code that originates the error: (file: cometa.hpp)

constexpr inline bool is_pod_like = std::is_pod_v<T> || details::is_pod_like_impl<T>::value;

std::is_pod is deprecated. If I comment the std::is_pod_v<T> ||, then it compiles.

I have an old project and I can't change it all to LLVM. What should I do in this case to work with VS22 v143?

I'm not sure if I can leave it commented or what would be the equivalent. I would greatly appreciate any help.

Project:

/std:c++latest Visual Studio 2022 - 17.7.2 Kfr 5.0.3 Windows 11 22H2

dancazarin commented 9 months ago

C4996 is a warning not an error. Do you have 'Treat warnings as errors' setting turned on or /WX flag in your project? Anyway, you can suppress this warning to continue using latest VS2022. As for the deprecation itself, this will be fixed in the next release of KFR.

dpieve commented 9 months ago

Indeed, I see it's a warning and not an error. 'Treat warnings as errors' is set to 'No'. I will try to suppress it. Thank you for the reply

dpieve commented 9 months ago

I'd like to add how to reproduce: Create an empty C++ project > add KFR path to include directories > set language to C++ latest > create main.cpp and add the code from my post.

dancazarin commented 9 months ago

Since KFR 5.1.0 (just pushed to dev) std::is_pod isn't used, so the C4996 warning/error should gone.

dpieve commented 9 months ago

Thank you once again! I tested it here, KFR 5.1.0 doesn't have those warnings. However, I get a compile error in Release x64 when I have the following code with Platform toolset VS22 v143:

#include "kfr/all.hpp"

int main() {
    univector<f32, 127> taps;
    const expression_handle<f32> window = kfr::to_handle<expression_blackman_harris<f32>>(kfr::window_blackman_harris<f32>(taps.size()));
    return 0;
}

It shows error C1001:

PathToKfr\kfr\include\kfr\math\impl\sin_cos.hpp(61): fatal error C1001: Internal compiler error.

It compiles in Debug x64

/std:c++latest, VS2022 - 17.7.2, KFR 5.1.0

if Platform toolset = LLVM (clang-cl), it works fine (Debug and Release)

The compiler options when Release x64 (KfrTests.cpp is where my main is):

/permissive- /ifcOutput "x64\Release\" /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc143.pdb" /Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "_CRT_SECURE_NO_WARNINGS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /std:c++latest /FC /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\KfrTests.pch" /diagnostics:column 
dpieve commented 9 months ago

The compiler error mentioned in my previous message only happens if C/C++ > Optimization > Inline Function Expansion is enabled (it came enabled by default when I created an empty VS C++ project).

Only when Inline Function Expansion is Disabled (/Ob0), the compiler error doesn't occur.

dancazarin commented 8 months ago

Could you provide the exact version of VS compiler? cl --version in VS shell.

dpieve commented 8 months ago

Could you provide the exact version of VS compiler? cl --version in VS shell.

Yes. Compiler version: 19.37.32822 for x86. VS is 17.7.2, version 4.8.09032.

dancazarin commented 8 months ago

The fix for Visual Studio compiler error has been implemented in dev branch. Could you test it in your environment?

dpieve commented 8 months ago

It works in my environment. I compiled it in Debug and Release x64 mode. The compiler error was fixed. Thank you.

dancazarin commented 8 months ago

The ICE has been fixed using more robust method. Already in main. Please pull new changes in case this ICE happens again.