pinMode, digitalWrite, digitalRead


I just come across this issue by hazard.

I have a digitalWrite(pin, value) statement where "pin" is a number and not a symbol. The number is out of the range for the real board (35 for an ATtiny of 8 pins), by mistake. At the compiling time is no error message for it.

I tried also with digitalRead and pinMode for Arduino Pro or Pro Mini, for Arduino Uno and for my target board with Attiny25/45/85. I tried on three computers with different versions of Windows. The same result: no error message for out of range concerning the "pin" number.

Is it normal behavior for the compiler? B.t.w. I tried only with the last version of Arduino IDE 1.8.5.

Thank you,


You are responsible for keeping the numbers in range.


I got it.

Thank you for the fast reply!

Have an amazing day!

There is a check, but it is run-time, not compile time. Since digitalWrite() allows variables as parameters, and not just constants, it doesn't do a compile time check.

Compilers don't check values passed to functions, they check types. If the register specifier was an
enumeration rather than an integer that would be a different matter I think.