there are a lot of Posts concerning A6 and A7. I add another one. Sorry for that.
In my project there was a troubling sideffect of my (I know by now: faulty) pinMode(A6,INPUT_PULLUP) instruction. A seemingly random bit in my data segment was set to 1.
As far as I analysed the source code, pinMode (version of 28 September 2010 by Mark Sproul) uses a lookup table digital_pin_to_port_PGM, but that table does not have an entry for A6 and A7. So the array is accessed out of bounds. Nevertheless pinMode tests the table value for the value NOT_A_PIN, but that may not be set due to the out of bounds access and hence pinMode sets an random bit.
This is a mean situation, since it will almost never be realized, but may cause a severe program malfunction.
Should'nt this be changed in the Arduino ? Just add two entries NOT_A_PIN in the lookup table. Then pinMode should work fine.
I think the point was that the table should have an entry for A6 and A7, so that calling pinMode() with those pins will not produce undefined behavior. Better approach would be for pinMode() to check that the number passed to it is within a valid range, instead of adding extra entries to the table.
Incidentally, in addition to INPUT_PULLUP, there is never any reason to call pinMode() on those pins. Calling analogRead() does any necessary setup for the analog inputs.
Sure, there is no point in calling pinMode for A6/A7. That was not was I was trying to say. Sorry, if I made that not clear enough.
david_2018 is absolutely right when he says, my proposal is to prevent undefined behavior. Thanks david for pointing that out.
But since the table is not long enough, I do not understand why is NOT_A_PIN checked in pinMode after all, when it is never set. Ok, mybe some (future) variant can set NOT_A_PIN.
david_2018: I also thought of checking the Pin number, but pinMode is in core, not in variants. Only digital_pin_to_port_PGM is in variants.
I think it is worth the pain, because the problem sneaks in silently. It took me 4 weeks, to nail it down. It caused no harm at all to me, but it might to others.