AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb

[BUG] NanoVDB line fails with syntax error in /std:c++20

Open Beginner friendly
#1,521 5 comments 1 reaction 0 assignees View on GitHub
bug nanovdb
Dominant language
C++
Stars
3.4k
Forks
774
Avg merge
3d 9h
Merged PRs (30d)
34

Description

### Environment
**Operating System:** Windows 10 Pro
**Version / Commit SHA:** [current master HEAD](https://github.com/AcademySoftwareFoundation/openvdb/commit/65a39c880769da171261b5d00b2e350a8c015b26)
**Other:** Visual Studio 2022 using C++20

### Describe the bug
Using ISO C++20 Standard (/std:c++20) causes the following errors in Visual Studio 2022:

```
Error C2760 syntax error: ')' was unexpected here; expected ';' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C2760 syntax error: 'const' was unexpected here; expected ')' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C3329 syntax error: expected 'identifier' not ')' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C3878 syntax error: unexpected token ')' following 'expression_statement' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C3878 syntax error: unexpected token '>' following 'simple_declaration' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
```

[The actual line in GridBuilder.h causing the syntax error](https://github.com/AcademySoftwareFoundation/openvdb/blob/65a39c880769da171261b5d00b2e350a8c015b26/nanovdb/nanovdb/util/GridBuilder.h#L258)

I believe [this documentation](https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c2760?f1url=%3FappId%3DDev16IDEF1%26l%3DEN-US%26k%3Dk(C2760)%26rd%3Dtrue&view=msvc-170#:~:text=The%20new%20lambda%20processor%20available%20under%20/std%3Ac%2B%2B20%20or%20later%2C%20or%20under%20/Zc%3Alambda%2C%20enables%20some%20new%20conformance%2Dmode%20syntactic%20checks%20in%20generic%20lambdas.%20The%20legacy%20lambda%20processor%20compiles%20this%20code%20without%20warnings%2C%20but%20the%20new%20lambda%20processor%20produces%20error%20C2760%3A) is related to the error.

### To Reproduce
Steps to reproduce the behavior:
1. Using the environment specified above, attempt to build a C++ file having `#include `, or in my case, `#include ` which eventually includes GridBuilder.h.

### Expected behavior
No syntax errors, as is seen on C++17 and earlier

Contributor guide

Open the contributing guide

Research direction

Open nanovdb/nanovdb/util/GridBuilder.h at the reported line and reproduce the include failure with Visual Studio 2022 using /std:c++20, preferably through the minimal file described in the issue. Compare the behavior with C++17 and inspect the related OpenToNanoVDB.h include path. Done means the header builds under C++20 without the reported syntax errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.