Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvcc compiler warning; doctest.h(4138): warning : expression has no effect #454

Closed
mojca opened this issue Jan 6, 2021 · 3 comments
Closed

Comments

@mojca
Copy link

mojca commented Jan 6, 2021

Description

I've seen some claims that doctest shouldn't be throwing any warnings ;)

It does it for me, on the following two lines, when building from CMake in Release configuration under Visual Studio 2019 using the latest nvcc from CUDA 11.2:

_CrtSetReportMode(_CRT_ASSERT, prev_report_mode);
_CrtSetReportFile(_CRT_ASSERT, prev_report_file);

Full invocation (generated by CMake):

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nvcc.exe" -gencode=arch=compute_52,code=\"compute_52,compute_52\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_60,code=\"compute_60,compute_60\" -gencode=arch=compute_60,code=\"sm_60,compute_60\" -gencode=arch=compute_61,code=\"compute_61,compute_61\" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -gencode=arch=compute_75,code=\"compute_75,compute_75\" -gencode=arch=compute_75,code=\"sm_75,compute_75\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29617\bin\HostX64\x64" -x cu   -I"D:\path\to\project" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include"     --keep-dir x64\Release  -maxrregcount=0  --machine 64 --compile -cudart static -std=c++14 -Xcompiler="/EHsc -Ob2"   -D_WINDOWS -DNDEBUG -DSOURCE_PATH_SIZE=38 -D"CMAKE_INTDIR=\"Release\"" -D"CMAKE_INTDIR=\"Release\"" -D_MBCS -Xcompiler "/EHsc /W1 /nologo /O2 /Fdtest_kernels.dir\Release\vc142.pdb /FS   /MD /GR" -o test_kernels.dir\Release\test_kernels.obj "D:\path\to\project\tests\test_kernels.cu"

Steps to reproduce

Add a simple cuda file (*.cu) to a CUDA-enabled CMake-based project and compile it. Inclusion of the header is sufficient to trigger the warning.

Extra information

  • doctest version: v2.4.4
  • Operating System: Windows 10
  • Compiler+version: nvcc (Cuda compilation tools, release 11.2, V11.2.67)

PS: feel free to close this as invalid.

@onqtam
Copy link
Member

onqtam commented Jan 6, 2021

Hello, and thanks for reporting this issue!

Can you paste the exact warning, as I don't have a CUDA compiler setup at hand? Does it happen only in Release?

And can you try putting a (void) cast in front of those 2 statements and let me know if that solves it for you? Thanks!

@mojca
Copy link
Author

mojca commented Jan 6, 2021

This is literally the complete warning (repeated a bunch of times):

C:\path\to\doctest.h(4138): warning : expression has no effect

Yes, this only happens with the release build. Some flags used with the release (incomplete list)

-Xcompiler="/EHsc -Ob2" -DNDEBUG -D_MBCS -Xcompiler "/EHsc /W1 /nologo /O2 /FS   /MD /GR"

some flags used with the debug configuration:

-Xcompiler="/EHsc -Zi -Ob0" -g -D_MBCS -Xcompiler "/EHsc /W1 /nologo /Od /FS /Zi /RTC1 /MDd /GR"

Yes, using (void) as in

(void)_CrtSetReportMode(_CRT_ASSERT, prev_report_mode);
(void)_CrtSetReportFile(_CRT_ASSERT, prev_report_file);

helps.

onqtam added a commit that referenced this issue Jan 7, 2021
@onqtam
Copy link
Member

onqtam commented Jan 7, 2021

I pushed a fix for this in the dev branch - will release a new version in the next couple of weeks!

@onqtam onqtam closed this as completed Feb 2, 2021
onqtam added a commit that referenced this issue Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants