[PATCH] Use implicit zero initialize for the whole array.

Lubomir I. Ivanov neolit123 at gmail.com
Mon Dec 9 15:27:28 UTC 2013


On 10 December 2013 01:08, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> On 9 December 2013 23:37, Anton Lundin <glance at acc.umu.se> wrote:
>> Clang yelled about it, and it looks prettier. It also felt kinda strange
>> to explicit initialize the first element to zero and the rest to zero
>> implicit.
>>
>> Signed-off-by: Anton Lundin <glance at acc.umu.se>
>> ---
>>  qt-ui/maintab.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
>> index 9810ab5..21451d9 100644
>> --- a/qt-ui/maintab.cpp
>> +++ b/qt-ui/maintab.cpp
>> @@ -442,7 +442,7 @@ void MainTab::updateDiveInfo(int dive)
>>                 ui.otuText->setText(QString("%1").arg(d->otu));
>>                 ui.waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE));
>>                 ui.airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE));
>> -               volume_t gases[MAX_CYLINDERS] = { 0 };
>> +               volume_t gases[MAX_CYLINDERS] = {};
>
> huh, that's odd. i don't see anything wrong in initializing that
> buffer of 8 int values to zero.
> what was the exact clang message?
>

ok, for { 0 }, GCC 4.4.0 emits a "missing braces around initializer
for" with "-Wall" but that actually looks like a compiler bug.
no complains for  = {};

= {{0}} should also be an option, given we are initializing a struct.

lubomir
--


More information about the subsurface mailing list