In reply to jmlemay:
It is exactly doing what you have written.
cfg.foo is never assigned a value. It is only declared in your config object.
But you have a few additional weaknesses in your code:
See here
class base_test extends uvm_test;
string m_foo;
my_pkg::cfg_c cfg;
`uvm_component_utils_begin(baae_test)
`uvm_field_string(m_foo, UVM_ALL_ON)
`uvm_compoennt_utils_end
function new(string name="base_test", uvm_component parent);
super.new(name, parent);
endfunction : new
virtual function void build_phase(uvm_phase phase);
this.cfg = my_pkg::cfg_c::type_id::create("cfg");
$display("test.m_foo = '%s'", this.m_foo);
$display("test.cfg.m_foo = '%s'", this.cfg.m_foo);
endfunction : build_phase
...
endclass : base_test