Skip to content

Remove the unused loop counter in printSpeed - #66

Merged
galekseev merged 1 commit into
masterfrom
cursor/remove-unused-loop-counter-in-printspeed-9783
Aug 8, 2026
Merged

Remove the unused loop counter in printSpeed#66
galekseev merged 1 commit into
masterfrom
cursor/remove-unused-loop-counter-in-printspeed-9783

Conversation

@galekseev

Copy link
Copy Markdown

Summary

printSpeed keeps a loop counter that nothing reads, and clang warns about it on every build:

Dispatcher.cpp:547:16: warning: variable 'i' set but not used [-Wunused-but-set-variable]

The counter is a leftover. It was introduced in 89ed68c (2018-03-11) and was read at the time, supplying the GPU label via toString(i). The very next day e46719d switched that to toString(e->m_index) so the printed index would match the device index rather than the vector position, but left the counter and its increment behind. Nothing has read it since.

gcc does not report this even with -Wall -Wextra, because it treats ++i as a read of i. clang follows the def-use chain and sees the value never escapes, which is why the warning only shows up on macOS builds, where g++ is clang.

Test plan

  • Dispatcher.o is byte-identical before and after, in both the release and the PROFANITY_DEBUG configuration, so the compiler was already discarding the counter
  • CI builds the image

Made with Cursor

clang warns on every build:

  Dispatcher.cpp:547:16: warning: variable 'i' set but not used
  [-Wunused-but-set-variable]

The counter is a leftover. It was introduced in 89ed68c (2018-03-11) and
was read at the time, supplying the GPU label via toString(i). The very
next day e46719d switched that to toString(e->m_index) so the printed
index would match the device index rather than the vector position, but
left the counter and its increment behind. Nothing has read it since.

gcc does not report this even with -Wall -Wextra, because it treats ++i
as a read of i. clang follows the def-use chain and sees the value never
escapes. That is why the warning only shows up on macOS builds, where
g++ is clang.

Dispatcher.o is byte-identical before and after in both the release and
the PROFANITY_DEBUG configuration, so the compiler was already
discarding the counter.

Co-authored-by: Gleb Alekseev <alekseev.gleb@gmail.com>
@galekseev
galekseev merged commit 90c61e3 into master Aug 8, 2026
1 check passed
@galekseev
galekseev deleted the cursor/remove-unused-loop-counter-in-printspeed-9783 branch August 8, 2026 18:53
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.

2 participants