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

C

Clemens Hintze

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top