Why is the default dev profile in the cargo Book inconsistent with that in practice?

// main.rs
#[derive(Debug)]
struct Animal<'a>{
    name:&'a str,
    age:i32
}
static my_dog: Animal=Animal{
    name:"bzzb",
    age:2
};
fn main(){
    println!("{:?}",my_dog);
}

that is profile in cargo book Profiles - The Cargo Book

// when cargo build, and i print the static variable in gdb it has been initialized
(gdb) p learn::my_dog 
$1 = learn::Animal {name: "bzzb", age: 2}

// but when cargo build with profile provided by cargo document, it seems that my_dog has not been initialized
(gdb) p learn::my_dog 
$1 = learn::Animal {name: "", age: 0}

// until i excute run command the variable be initialized
(gdb) b main
Breakpoint 1 at 0x7b50
(gdb) r
Starting program: /home/oslab/repos/learn-rust/target/debug/learn 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, 0x000055555555bb50 in main ()
(gdb) p learn::my_dog 
$2 = learn::Animal {name: "bzzb", age: 2}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.