Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Usage of default constructed slice allowed in valarray? [long]

Thread Tools

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

Clemens Hintze
Posts: n/a

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 ...

#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];

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;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

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

Thanks in advance.

Best regards,
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why defining a constant in a method is not allowed but usingself.class.const_set is allowed? IƱaki Baz Castillo Ruby 13 05-01-2011 06:09 PM
typedef of template classes are always default constructed? aaragon C++ 12 11-08-2006 04:34 PM
Querying a dynamically constructed html table ukrbend HTML 3 11-29-2005 08:52 PM
Default constructed random access iteratators Kristoffer Vinther C++ 1 05-17-2005 11:01 PM
definition of template static default-constructed data members impossible? Paul C++ 8 12-10-2004 08:48 AM