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

Discussion in 'C++' started by Clemens Hintze, Nov 7, 2005.

  1. 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.
     
    Clemens Hintze, Nov 7, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim West
    Replies:
    2
    Views:
    514
    Jim West
    Dec 23, 2003
  2. Paul
    Replies:
    8
    Views:
    447
    Rob Williscroft
    Dec 10, 2004
  3. Kristoffer Vinther

    Default constructed random access iteratators

    Kristoffer Vinther, May 17, 2005, in forum: C++
    Replies:
    1
    Views:
    350
    Ron Natalie
    May 18, 2005
  4. aaragon
    Replies:
    12
    Views:
    1,322
    aaragon
    Nov 8, 2006
  5. john
    Replies:
    2
    Views:
    374
    James Kanze
    Dec 16, 2007
Loading...

Share This Page