This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to initializer-list overload resolution
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 24 Jul 2009 18:40:10 +0200
- Subject: Re: C++ PATCH to initializer-list overload resolution
- References: <4A69DB9B.6020405@redhat.com>
Jason Merrill wrote:
> Paolo's message with is patch for library DR 630 noted that assigning
> { } to a valarray was using the element assignment op rather than the
> initializer-list version. Which is wrong; we always want to prefer
> the initializer-list overload when we get { }. I had implemented that
> for comparison to calling a constructor, but not for conversion to
> scalar type. Fixed thus.
Many thanks Jason. I also applied the below (per my original intentions ;)
Paolo.
//////////////////
2009-07-24 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/26_numerics/valarray/dr630-2.cc: Extend.
Index: testsuite/26_numerics/valarray/dr630-2.cc
===================================================================
--- testsuite/26_numerics/valarray/dr630-2.cc (revision 150059)
+++ testsuite/26_numerics/valarray/dr630-2.cc (working copy)
@@ -35,24 +35,29 @@
valarray<int> v2(0, 10);
- v2 = { -1, -1, -1, -1, -1 };
- VERIFY( v2.size() == 5 );
- VERIFY( v2.min() == -1 );
- VERIFY( v2.max() == -1 );
+ v2 = { };
+ VERIFY( v2.size() == 0 );
- valarray<int> v3(0, 5);
+ valarray<int> v3(0, 10);
- v3 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
- VERIFY( v3.size() == 10 );
+ v3 = { -1, -1, -1, -1, -1 };
+ VERIFY( v3.size() == 5 );
VERIFY( v3.min() == -1 );
VERIFY( v3.max() == -1 );
- valarray<int> v4(0, 10);
+ valarray<int> v4(0, 5);
v4 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
VERIFY( v4.size() == 10 );
VERIFY( v4.min() == -1 );
VERIFY( v4.max() == -1 );
+
+ valarray<int> v5(0, 10);
+
+ v5 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
+ VERIFY( v5.size() == 10 );
+ VERIFY( v5.min() == -1 );
+ VERIFY( v5.max() == -1 );
}
int main()