473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 1567

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christian Brechbühler | last post by:
The template std::valarray behaves pretty much like a mathematical vector. Arithmetic operators apply elementwise. Now I'd like to extend this to a user-defined type, e.g., complex. ...
9
by: Pierre Senellart | last post by:
The C++ standard states (26.3.2.1), about std::valarray constructors: > explicit valarray(size_t); > > The array created by this constructor has a length equal to the value of > the argument....
11
by: ma740988 | last post by:
I'm perusing a slide with roughly 12 bullets spread across 3 pages. Each bullet reflects 'advice'. I'm ok with all but 1 bullet, more specifically the bullet that states: " Avoid the STL unless...
0
by: Travis Oliphant | last post by:
This post is to gather feedback from the wider community on PEP 357. It is nearing the acceptance stage and has previously been discussed on python-dev. This is a chance for the wider Python...
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
3
by: Sirisha | last post by:
I am using the following code to get the CPU usage PerformanceCounter myCounter; myCounter = new PerformanceCounter(); myCounter.CategoryName = "Processor"; myCounter.CounterName = "%...
3
by: Bas | last post by:
Hi, stupid question, but would it be possible to somehow merge xrange (which is supposed to replace range in py3k) and slice? Both have very similar start, stop and step arguments and both are...
10
by: Chris Forone | last post by:
Hello Group, there is some memberfunc for std::valarray to return a pointer to the first element in the array. How do i use this? Thanx a lot. HAND Chris
2
by: john | last post by:
Hi, in TC++PL3 on page 665, regarding valarray member functions, it is mentioned: "valarray operator-() const; // result= -v for every element // similarly: +, ~, !" I checked the web and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.