470,596 Members | 1,331 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Usage of default constructed slice allowed in valarray? [long]

Hello,

I have a question concerning the usage of default constructed
std::slice instances.

Our company currently validate the GNU-G++ 3.4 compiler against the
ISO/IEC 14882:2003 standard for compliance. We are using a commercial
testsuite that is sold explicitely for such validation purposes.

Now there occurs a problem, where the corresponding test produces a
core dump therefore rendering the test as failure.

Reading the standard, I am thinking the test implementation is okay.
But our G++ supplier do not agree with me. We both are digging in the
standard and cannot agree on its meaning for that purpose. So I would
like to ask for other opinions as well.

So here we go ...

----------------------8X-------------------------
#include <valarray>

int main() {
const std::valarray<int> va(3);
//std::slice sl; // (1) Uncomment this procduces core dump
//std::slice sl(0,0,0); // (2) Uncomments this, all wents well

std::valarray<int> va2 = va[sl];
}
----------------------8X-------------------------

In the testsuite the code is with like this with line (1) uncommented.
The test execution dumps core. However if I did uncomment (2) instead,
the program will runs fine without dumping core.

My question is now, if it is forbidden - following the standard- that
I use a default constructed slice [like in (1)] to select elements
within an valarray?

In Sec 26.3.4.1;1 there is written

"The default constructor for slice creates a slice which specifies no
elements. A default constructor is provided only to permit the
declaration of arrays of slices. The constructor with arguments for
a slice takes a start, length, and stride parameter."

I interpret this sentence so, that a default constructed slice specify
no elements like this regular constructed one:

std::slice sl(0,0,0);

I do not interpret the sentence concerning "(...) provided only (...)"
above the way, that any other usage of a default constructed slice
(besides declaring arrays of slices) would be forbidden and therefore
undefined.

Do anybody know better, how the Standard has meant usage of default
constructed slices? Result such usage in undefined behavior and
therefore I should expect a possible core dump?

If so, then I would have to bother our supplier of the compliance
testsuite to fix theirs tests, as they wouldn't be standard compliant
any more ... but before I bother them, I would like to hear some more
opinions!

Thanks in advance.

Best regards,
Clemens.
Nov 7 '05 #1
0 1479

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Christian Brechbühler | last post: by
9 posts views Thread by Pierre Senellart | last post: by
11 posts views Thread by ma740988 | last post: by
3 posts views Thread by Sirisha | last post: by
3 posts views Thread by Bas | last post: by
10 posts views Thread by Chris Forone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.