Skip to content

Fix gcc, clang and msvc warnings#607

Open
skwerner wants to merge 16 commits into
RenderKit:masterfrom
skwerner:fix-all-warnings
Open

Fix gcc, clang and msvc warnings#607
skwerner wants to merge 16 commits into
RenderKit:masterfrom
skwerner:fix-all-warnings

Conversation

@skwerner

Copy link
Copy Markdown
Contributor

No description provided.

- Add explicit copy constructors to BBox, LBBox, CubicBezierCurve
- Add explicit copy assignment operator to range
- Fix base class initialization in Atomic copy constructor
- Suppress -Wunused-parameter, -Wcast-function-type, -Wdeprecated-copy
@stefanatwork stefanatwork self-assigned this Jun 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@stefanatwork stefanatwork changed the title Fix gcc and clang warnings Fix gcc, clang and msvc warnings Jun 17, 2026
@stefanatwork stefanatwork requested a review from Copilot June 17, 2026 06:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 177 out of 177 changed files in this pull request and generated 3 comments.

Comment thread kernels/geometry/trianglev.h Outdated
Comment thread kernels/geometry/quadv.h Outdated
Comment thread tutorials/common/imgui/CMakeLists.txt Outdated
stefanatwork and others added 10 commits June 17, 2026 09:27
- Fix viewer.cpp: wrap extern C variables with initializers in extern C blocks
- Fix viewer.cpp: remove redundant renderFrameStandard declaration
- Fix verify.cpp: add [[fallthrough]] for case 20 fall-through
- Fix verify.cpp: remove extra semicolon after ALIGNED_CLASS_ macro
- Fix constraints.h: remove extra semicolon after ALIGNED_CLASS_ macro
- Fix intersection_filter_device.cpp: construct Ray directly instead of default-init + assign
- Fix clang.cmake: add -Wno-c++17-attribute-extensions for [[fallthrough]] in C++11 mode

Both GCC-15 and Clang-21 builds with tutorials now emit zero warnings/errors.
- Add -Wall -Wextra -Werror with appropriate suppressions to dpcpp.cmake
- Remove unused hasDriverExtension function and hDriver variable
- Fix const return types on uint32_t/bool functions
- Fix sign comparison in instance_array.h and thread.cpp
Add /W4 (high warning level) and /WX (warnings as errors) to the MSVC
build. Suppress a curated set of warnings that fire on intentional
patterns throughout the codebase:

  /wd4100 - unreferenced formal parameter (template/virtual boilerplate)
  /wd4127 - constant conditional expression (template/SIMD idioms)
  /wd4201 - nameless struct/union (SIMD vector types)
  /wd4244 - narrowing conversion (geometry/SIMD math)
  /wd4267 - size_t narrowing (index arithmetic)
  /wd4324 - struct padded for alignment (SIMD alignment specifiers)
  /wd4512 - assignment operator not generated (const-member types)
  /wd4714 - __forceinline not inlined (compiler decision)
  /wd4702 - unreachable code (false positives in inlined templates)
  /wd4800 - implicit int-to-bool (flag/mask code)

Also strip the CMake-injected /W3 so /W4 is unambiguous.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve all MSVC warnings that fire under /W4 /WX in the core library
(common/) and BVH kernels (kernels/). Changes are purely mechanical
renames and casts — no logic is altered.

Warning categories fixed:
  C4189  unused initialized local variable (alloc.h: 'done' only live
         inside assert, which is a no-op in Release; add (void)done)
  C4245  signed/unsigned mismatch (ray.mask = -1 -> 0xFFFFFFFFu, and
         various index/count assignments)
  C4456  local declaration hides outer local (loop-variable shadowing)
  C4457  local declaration hides function parameter
  C4458  local declaration hides class member (lambda captures, etc.)
  C4459  local declaration hides global (parameter named same as global)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve all MSVC warnings under /W4 /WX across every tutorial and the
shared tutorial infrastructure.

Warning categories fixed:
  C4189  unused initialized local (alloc.h 'done' pattern)
  C4245  signed/unsigned mismatch — ray/shadow mask initialisation
         (mask = -1 -> 0xFFFFFFFFu) and size_t argument mismatches
  C4389  signed/unsigned mismatch in == operator
  C4456  local hides outer local — shadowed loop variables (i, j),
         mesh, hgeom, vertices, quad, tri
  C4457  local hides function parameter (v in geometry lambdas)
  C4458  local hides class member (N, ivariant, sampler)
  C4459  local hides global — renderPixelStandard/postIntersect/
         createPoints 'data' parameter renamed to 'td' throughout;
         quaternion_motion_blur 'qdc' parameter renamed
  C4505  unreferenced static function — benchmark.h helpers changed
         from 'static MAYBE_UNUSED' to 'inline'
  C5051  [[maybe_unused]] / [[fallthrough]] require /std:c++17;
         replaced with MAYBE_UNUSED macro and /* falls through */
         comments respectively

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The SYCL_ONEAPI_ICX detection checked for 'icx' and 'icpx' but not for
'icx-cl', the MSVC-compatibility-mode variant of the ICX compiler used
when building with Ninja/CMake on Windows. Without this match the
cmake logic fell through to the Linux/Clang flag path, injecting flags
such as -std=c++17, -fvisibility=hidden and -ffp-model=precise that
icx-cl rejects with -Werror,-Wunknown-argument errors.

Add 'icx-cl' to the SYCL_ONEAPI_ICX name check so the correct Windows
ICX flag set is selected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Three classes of warning fixed, all from the ICX SYCL device compiler:

1. [-Wundefined-internal] sycl::detail::get_spec_constant_symbolic_ID
   has internal linkage but is not defined.

   'const' variables at C++ namespace scope have *internal* linkage by
   default (same as 'static const').  The SYCL compiler generates a
   per-variable helper function with matching linkage; when that linkage
   is internal the function has no definition visible to the SYCL
   runtime and the warning fires.

   Fix: declare all sycl::specialization_id objects as 'inline const'.
   C++17 inline variables have external linkage, so the compiler emits
   one uniquely-identifiable definition.  viewer_device_debug.cpp
   re-declares the same spec_feature_mask as inline const; the ODR
   rule merges it with viewer_device.cpp's definition at link time.

   Files changed: viewer_device.cpp, viewer_device_debug.cpp,
                  next_hit_device.cpp, pathtracer_device.cpp

2. [-Wuninitialized-const-pointer] imgui_widgets.cpp: 'empty_string'
   passed as a const-pointer before being initialised.

   Fix: zero-initialise the STB_TEXTEDIT_CHARTYPE variable at the point
   of declaration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
stefanatwork and others added 4 commits June 17, 2026 09:35
Use (int)(1u << 31) instead of 1 << 31 to avoid -Werror=shift-overflow=
when shifting into the sign bit of a signed int. Keeps the constant type
consistent with all other CPU_FEATURE_BIT_* constants.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The PR renamed locals v0/v1/v2 to lv0/lv1/lv2 to fix shadowing warnings,
but forgot to update the store_nt() call in fill(), causing it to pass the
stale member vectors instead of the newly loaded triangle vertices.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
update() declared locals lv0/lv1/lv2 but used the member v3 directly,
leaving stale data in unused lanes and being inconsistent with the other
vertex vectors. Add a zero-initialized local lv3 and pass it into the
placement-new, matching the pattern used by fill() and by trianglev.h.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… Clang

The previous change stopped applying FLAGS_LOWEST on MSVC and passed
-Wno-uninitialized-const-pointer to all non-MSVC compilers including GCC,
which may not support that flag. Restore the unconditional FLAGS_LOWEST
(matching master) and gate the Clang-specific warning suppression behind
a Clang compiler check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 177 out of 177 changed files in this pull request and generated 1 comment.

Comment thread tutorials/user_geometry/user_geometry_device.cpp
Comparing ray.instID[0] (unsigned) to -1 triggers -Wsign-compare.
Use RTC_INVALID_GEOMETRY_ID consistently, matching the check on line 775.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 177 out of 177 changed files in this pull request and generated no new comments.

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

Successfully merging this pull request may close these issues.

4 participants