[Bug c++/86135] At run time, when the constructor tries to construct an objects element with a initializer-list (using c++11 style) is giving segmentation fault. The old style of initialize with parenthesis is working properly.

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 13 16:04:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86135

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Sabetay Toros from comment #4)
> If it is not a bug then why the parenthesis version is working.

Because the rules for direct-initialization (with parentheses) and
list-initialization (with braces) are different. Different rules means
different things happen.

> Moreover Strastroup advice is to use  the initializer list version in
> constructing objects not the parenthesis.

That's not always good advice.

> Besides Clang does not suffer with that kind of error.  Both styles are
> working.

Clang does not follow the standard correctly in this respect.


More information about the Gcc-bugs mailing list