This is different:
void loop() {
char * local_string = "Will this string survive until second call to print_buffer()?";
print_buffer();
buffer[1] = local_string;
}
Now you are not asking for a local array to be allocated but a local pointer. The compiler generates a much shorter loop:
void loop() {
char * local_string = "Will this string survive until second call to print_buffer()?";
print_buffer();
ea: 0e 94 5f 00 call 0xbe ; 0xbe <_Z12print_bufferv>
buffer[1] = local_string;
ee: 80 e0 ldi r24, 0x00 ; 0
f0: 91 e0 ldi r25, 0x01 ; 1
f2: 90 93 6f 01 sts 0x016F, r25
f6: 80 93 6e 01 sts 0x016E, r24
}
fa: 08 95 ret
This is actually a bit dodgy because you have converted a const pointer to non-const. I think there is a warning about that. Ah yes, if you turn on verbose compiling:
sketch_sep20a.cpp: In function 'void loop()':
sketch_sep20a.cpp:17: warning: deprecated conversion from string constant to 'char*'