Array not loading with values set

I did this recently on a few others sketches and still works on those but does not work on my new project or this MCVE

const uint8_t PROGMEM clock_set_arrow_display[] = {1,1,1,1, 9, 2,2, 9, 3,3, 9, 4,4, 9, 5,5, 9,9,9,9};
uint8_t clock_idx=1;

void display_clock_set()
 {
  uint8_t x;
  Serial.print(clock_idx); Serial.print(": ");
  for (x=0; x<20; x++)
   {
    Serial.print(clock_set_arrow_display[x]);
    if (clock_set_arrow_display[x] == clock_idx)
     {
//      Serial.print("x");
     }
     else
      {
//       Serial.print(" ");
      }
   }
  Serial.println(); 
 }

void setup() {
  Serial.begin(115200);
  display_clock_set();

}

void loop() {
  // put your main code here, to run repeatedly:

}

The output is

1: 00128000100128128128128128128128001350

The output should be

1: 11119229339449559999

The implementation in this sketch works:

const uint8_t PROGMEM display_arrow[] = {1,1,1,1, 0, 2,2, 0, 3,3, 9, 4,4, 9, 5,5, 9, 6,6, 9};
void display_clock_set()
 {
  uint8_t x;
  
  for (x=0; x<20; x++)
   {
    if (display_arrow[x] == clock_idx)
     { lcd.write(arrow_rt); } // print custom cursor arrow
     else
      { lcd.write(" "); }
   }
 }

Why does it work on those sketches (copy and paste) and not on this one?

Did you miss this PROGMEM ?

TheMemberFormerlyKnownAsAWOL:
Did you miss this PROGMEM ?

No. It's there. Same as it is in the working sketches.

check the tutorial

you didn't use pgm_read_byte_near

adwsystems:
No. It's there.

Yes it is, but "pgm_read_byte" is not.

Edit: pipped.

TheMemberFormerlyKnownAsAWOL:
Yes it is, but "pgm_read_byte" is not.

Edit: pipped.

But that is not in the working sketches.

adwsystems:
But that is not in the working sketches.

Ok. Thanks for letting us know.

TheMemberFormerlyKnownAsAWOL:
Ok. Thanks for letting us know.

I have no problems changing. Just wondering why it has worked in the past in several ways. In defining custom LCD characters

const PROGMEM uint8_t Arrow_RT[8]  = {0x00,0x04,0x04,0x04,0x1F,0x1F,0x0E,0x04};
const uint8_t arrow_rt = 0;

...

  lcd.createChar(arrow_rt, Arrow_RT);

...


lcd.write(arrow_rt);

using the array stored in PROGMEM. I have used this for years. Works fine, and there is no pgm_read_byte.

Is it happenstance, an issue with the IDE compiler, or sheer luck that this has worked in dozens of sketches?

because createChar expects data located in progmem?

Juraj:
because createChar expects data located in progmem?

Is that a question of a statement of fact? (because I don't know)

Hard to tell from the snippet posted.

I sort-of remember reading of instances here on the forum where PROGMEM arrays have magicked themselves into RAM (optimisations under peculiar circumstances), but maybe they were for particular platforms and/or particular IDE versions.

I certainly wouldn't want to depend on them always working.

adwsystems:
Is that a question of a statement of fact? (because I don't know)

it is a hypothesis I can't check, because I don't know the function

The pgm_... functions are always needed to pull data from PROGMEM. However, sometimes you get lucky. When the compiler see you screwed up AND the PROGMEM addresses are known at COMPILE-TIME then it's able to correct your error by doing what it thinks you wanted rather than what you told it.

That doesn't happen in your example as it a loop with run-time indexing.

Bottom line, read the reference provided and always use the pgm… functions.