AnalogIn read of ADC_VREF works in Debug profile but not in Release profile

I have a simple program that reads the ADC_VREF using AnalogIn.

The reading is correct when building in Debug profile using Mbed Studio.

But when building in Develop or Release profile it always reads 0.

Could anyone explain this?
Kind regards