Stream: ideas

Topic: unused warnings and dbg/expect


view this post on Zulip Richard Feldman (Mar 11 2023 at 14:20):

in https://jfmengels.net/safe-dead-code-removal/ @Jeroen Engels makes a great point about how side effects can make "unused" warnings unreliable

view this post on Zulip Richard Feldman (Mar 11 2023 at 14:21):

I wonder how dbg and expect should relate to that observation

view this post on Zulip Richard Feldman (Mar 11 2023 at 14:22):

since they are side effecting when running debug builds, but get removed for --optimize builds

view this post on Zulip Richard Feldman (Mar 11 2023 at 14:23):

for example, suppose I have a function argument which is only ever used inside a dbg and/or expect - clearly I wouldn't want to get an unused warning for that...that would be annoying; I actually do want it there!

Rather, I'd want it to get silently removed as an unused argument by --optimize (which LLVM should take care of)

view this post on Zulip Richard Feldman (Mar 11 2023 at 14:23):

I'm wondering if there are other scenarios where we might want to do something different though

view this post on Zulip Richard Feldman (Mar 11 2023 at 14:24):

can anyone think of any?

view this post on Zulip Ayaz Hafiz (Mar 11 2023 at 15:18):

I think those are the only ones without introducing more conditional compilation constructs


Last updated: Jun 16 2026 at 16:19 UTC