NC pin assign causes HardFault

If I use NC in a constructor, I have got a HardFault.
For example, recent program
[Check_VL53L0X_simple_ToF_Sensor - check program for VL53L0X_simple library | Mbed]
I run on mbed-os5.15.1.
Target Mbed boards are Nucleo-F446RE and L476RG.
main.cpp line 57.

VL53L0X sensor(i2c, D8); // XSHUT = D8 (or NC)

If I change D8 to NC, I have a run error message below.

– MbedOS Fault Handler –

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x8006912
Error Value: 0x20000000
Current Thread: main Id: 0x20001D94 Entry: 0x800CAF9 StackSize: 0x1000 StackMem: 0x20000768 SP: 0x20001718
For more info, visit: mbedos-error
– MbedOS Error Info –

= System will be rebooted due to a fatal error =
= Reboot count(=19) reached maximum, system will halt after rebooting
++ MbedOS Fault Handler ++

FaultType: HardFault

In the past, I could use NC and it worked well.
How do I use NC in the constructor?

You can use NC in the constructor, but when a pin can be NC you should check before setting/reading:

If (gpio0.is_connected()) {
gpio0=1;
}

Thank you for your help.
I modified above example program and it works fine.