According to this answer: https://stackoverflow.com/a/28338265/2013747, whether ={}
is needed is an open issue that clang and gcc originally chose to implement differently. Allowing ={}
to be omitted appears to be the direction that is preferred by the CWG, and clang 3.9 changed policy to reflect that.
Quoting CWG active issue #253:
253. Why must empty or fully-initialized const objects be initialized?
[]
Paragraph 9 of 8.6 [dcl.init] says:
If no initializer is specified for an object, and the object is of (possibly >cv-qualified) non-POD class type (or array thereof), the object shall be >default-initialized; if the object is of const-qualified type, the underlying >class type shall have a user-declared default constructor. Otherwise, if no >initializer is specified for an object, the object and its subobjects, if any, >have an indeterminate initial value; if the object or any of its subobjects are >of const-qualified type, the program is ill-formed.
What if a const POD object has no non-static data members? This wording requires an empty initializer for such cases [...]
(Emphasis added.) The conclusion here is that for compatibility with older compilers, and strict adherence to the standard, ={}
must be used unless there is a user-declared default ctor.
The old clang behavior resulted from the above conservative interpretation
of the language specification. CWG August 2011 meeting resolved:
Notes from the August, 2011 meeting:
If the implicit default constructor initializes all subobjects, no initializer should be required.
Source: http://open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253
As far as I know, this change has not yet been incorporated into any version of the C++ standard. Therefore, while omitting ={}
will likely continue to compile, and may in future be officially supported by the standard, it is not currently part of the official ISO standard.