This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/47453] Various non-conforming behaviors with braced-init-list initialization
- From: "schaub.johannes at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Jul 2011 12:24:06 +0000
- Subject: [Bug c++/47453] Various non-conforming behaviors with braced-init-list initialization
- Auto-submitted: auto-generated
- References: <bug-47453-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47453
--- Comment #5 from Johannes Schaub <schaub.johannes at googlemail dot com> 2011-07-29 12:23:35 UTC ---
(In reply to comment #4)
> struct A { int a[2]; A():a({1, 2}) { } };
>
> Should be valid. Example:
>
> class cond_variable
> {
> ::pthread_cond_t cond;
> public:
> constexpr cond_variable() : cond(PTHREAD_COND_INITIALIZER) {}
> };
>
> What is pthread_cond_t? Struct? Array? Scalar? How I can be sure this code is
> accepted in any case? Uniform initialization initially address this issue.
>
Why not say
constexpr cond_variable() : cond PTHREAD_COND_INITIALIZER { }
> Out of constructor one can use "=":
>
> ::pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
>
You can define it as follows to make it work in both cases
#define PTHREAD_COND_INITIALIZER {}