Curious Conditional Conundrum

Interestingly, I tried it (on a Uno) to see if it gave any compiler warnings because of a possible out of range condition being detected at compile time. It did not.

What I did notice was:
(a) that the value 'i' could even get to 17 (which should be impossible !)
(b) If, however, 'i' is declared as global instead of automatic, it all appears to work correctly even with the invalid format of the while statement while ((a[i] >= L[i]) && (i < 16)) { . . .

Anyway, little more can be said than the behaviour of code which causes undefined operations will be unpredictable.

#include "Arduino.h"
// #include "HardwareSerial.h"
// #include <stdint.h>

char buf[80] = {0} ;
// unsigned short i = 0;  // if 'i' is global, it appears to work in all cases even with an invalid while condition

const uint32_t L[16] = {0x00001000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000014de, 0x0000f9de, 0x0000a2f7, 0x00009cd6, 0x00005812, 0x0000631a, 0x00005cf5, 0x0000d3ed};

bool greaterThanOrEqualTo(uint32_t* a) { // WARNING: BROKEN!
  unsigned short i = 0;  // failure case visible only when 'i' is automatic.
  while ((a[i] >= L[i]) && (i < 16)) {  // invalid because "i" can reach 16 and cause an array read out of bounds
    // while( (i < 16) && (a[i] >= L[i]) ) {  // valid because i reaching 16 prevents the a[i] >= L[i] test being executed
    sprintf( buf, "i=%d, a=%lx, L=%lx \n", i, a[i], L[i] ) ;
    Serial.print( buf ) ;
    i += 1;
  }

  Serial.println(i);

  if (i == 16) {
    Serial.println("true");
    return true;
  }

  Serial.println("false");
  return false;
}


void setup() {
  Serial.begin(115200);
  while (!Serial) {
    delay(250);
  }

  uint32_t a[16] = {0x00001000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000014de, 0x0000f9de, 0x0000a2f7, 0x00009cd6, 0x00005812, 0x0000631a, 0x00005cf5, 0x0000d3ed};

  if (greaterThanOrEqualTo(a)) {
    Serial.println("true");
  } else {
    Serial.println("false");
  }
}


void loop() {}