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?

It's 8 or 4 bytes on the stack that are going to be removed by the optimizer. One reason D allows them is because of code generation.

No idea what linters exist for D, but they can do a better job than a compiler for things like this. Scope the warnings, change how strict they need to be, ...
  • Compiler doesn't... DLearner via Digitalmars-d-learn
    • Re: Compile... jmh530 via Digitalmars-d-learn
    • Re: Compile... Kapendev via Digitalmars-d-learn
      • Re: Com... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Com... Mindy Batek (0xEAB) via Digitalmars-d-learn
      • Re: Com... Forum User via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... Kapendev via Digitalmars-d-learn
        • Re:... Kapendev via Digitalmars-d-learn

Reply via email to