Compiler doesn't warn for declared but unused variables

jmh530 john.michael.hall at gmail.com
Fri Nov 27 17:07:54 UTC 2026


On Friday, 27 November 2026 at 16:34:07 UTC, DLearner wrote:
> This code
> ```
> void main() {
>
>    size_t a;
>    size_t b;
>
>    a = 1;
> }
> ```
> compiles and executes silently, despite 'b' declared but not 
> used.
>
> It's not an error, but should it not generate a warning?

For DMD, Walter generally isn't big on warnings.

LDC doesn't have a warning either, but I believe GDC does.


More information about the Digitalmars-d-learn mailing list