473,757 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange warning with deque.

I'm getting a strange warning at work when I compile any file in our
product that contains a deque of a particular struct. I don't understand
this warning, so I'm not sure if this is a Microsoft Windows issue, or
a C++ issue, so I'm posting it both to a Windows group and to a C++
group.

My OS is Windows 2000, and my compiler is Visual C++ 6.0.

The warning I'm getting is this:

c:\program files\microsoft visual studio\vc98\inc lude\deque(107) :
warning C4146: unary minus operator applied to unsigned type,
result still unsigned
c:\program files\microsoft visual studio\vc98\inc lude\deque(104) :
while compiling class-template member function
'void __thiscall std::deque<stru ct RT::TempHumData ,
class std::allocator< struct RT::TempHumData ::const_iterato r::_Add(int)'

The problem seems to occur when instantiating std::deque<Temp HumArray>.
The problem is with the "_Add()" function in std::deque. For some
reason, it attempts to do a unary minus on a unsigned type:

protected:
void
_Add(difference _type _N)
{
difference_type _Off = _N + _Next - _First;
difference_type _Moff = (0 <= _Off)
? _Off / _DEQUESIZ
: -((_DEQUESIZ - 1 - _Off) / _DEQUESIZ); // WARNING!!!
if (_Moff == 0)
_Next += _N;
else
{
_Map += _Moff;
_First = *_Map;
_Last = _First + _DEQUESIZ;
_Next = _First + (_Off - _Moff * _DEQUESIZ);
}
}

What's this "_Add()" function doing, anyway? To me, it looks like
some kind of pointer arithmetic, possibly implimenting subscripting.

The struct I'm storing in the deque is very simple:

struct TempHumData
{
TempHumData() : TimeStamp(0), Temp(0.0), Hum(0.0), Stage (0) {}
time_t TimeStamp; // VC++6 typedefs "time_t" to "long"
double Temp;
double Hum;
short Stage;
};

The only place where this is put into a deque is in this struct:

struct ZoneRTData
{
// Constructor (default or parameterized)
ZoneRTData (const ::zone& Zone = ::zone())
: Disabled(false) , Stage(0), Load(0), DbData(Zone) {}

// Database data:
::zone DbData;

// Zone deadband verification values:
deque<TempHumDa taTempHumDeque; // temperature/humidity history deque

// Zone disable/enable control values:
bool Disabled; // zone-disable flag; true if zone is disabled

// ACP/AHP exponential upstage boost control values:
ZoneLoadBoostDa ta ZoneBoost;

// ACP/AHP hysteresis contol values:
short Stage; // historical stage setting...
short Load; // historical load setting...
};

Objects of this type are put in a global map of ZoneRTData objects keyed by
unsigned int object ID numbers.

So... why am I getting this weird "unary minus on unsigned type" warning?
Is this a VC++6.0 thing? Or a C++ thing? Is there something bad I'm
doing in my code that is causing this?
--
Cheers,
Robbie Hatley
Tustin, CA, USA
lonewolfintj at pacbell dot net
(put "[usenet]" in subject to bypass spam filter)
http://home.pacbell.net/earnur/

Jul 4 '06 #1
2 2181
* Robbie Hatley:
>
My OS is Windows 2000, and my compiler is Visual C++ 6.0.
Upgrade to either MSVC 7.1 (free with Visual C++ Toolkit) or MSVC 8.0
(free with Visual Studio Express). Or use some other compiler such as
g++. MSVC 6.0 is very old and does not support template code very well.
Jul 4 '06 #2
"Robbie Hatley" <bo*********@no .spam.comwrote in message
news:vQ******** ************@ne wssvr21.news.pr odigy.com...
So... why am I getting this weird "unary minus on unsigned type" warning?
Is this a VC++6.0 thing? Or a C++ thing? Is there something bad I'm
doing in my code that is causing this?
The strange warning was added in a service pack, long after the library
code froze. It is indeed just a warning, and a misguided one at that.
The code is correct.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 4 '06 #3

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

Similar topics

16
12692
by: newsock | last post by:
What differences between queue, deque and priority_queue? And under what situations choose one of them to use? Thanks for your help!
7
4094
by: Jenny | last post by:
Hi, I have a class foo which will construct some objects in my code. some of the objects store int values into the data deque, while others store float values to the deque. template <class TYPE> class foo { protected:
9
3733
by: R.Z. | last post by:
i was wondering whether it pays off in terms of memory use to maintain lots of empty deques (it would be convenient for my algorithms but memory use is more important). and does the size of a deque depends on the size of its members even if the deque is empty? is there at all a way to check out how much memory my deque occupies? i've read that the sizeof operator cannot be used with dynamically allocated arrays so i figured it wouldn't give...
7
3480
by: Dan Trowbridge | last post by:
He everyone, I am just getting started with .NET and I am having a porting problem. I get and error in code that lookssomething like this (really stripped down but you get the idea)... class dt { std::deque< class dt > dtdq; };
6
1770
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that the individual elements in an array of ImageList's could be identified by the ID, thereby allowing re-ordering the array without harm. A person could identify by index into the array, but that would not be preserved by re-ordering (and re-ordering...
5
3504
by: Russell Warren | last post by:
Does anyone have an easier/faster/better way of popping from the middle of a deque than this? class mydeque(deque): def popmiddle(self, pos): self.rotate(-pos) ret = self.popleft() self.rotate(pos) return ret
5
6156
by: yancheng.cheok | last post by:
after reading http://www.codeproject.com/vcpp/stl/vector_vs_deque.asp, i realize that deque has its own speed advantage over vector in all the aspect (except for memory deallocation). does it mean that we should prefer deque over vector? (in contrast with c++ standard, which recommence vector over deque) thanks!
15
3534
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and you want to make a deque which can contain any objects of any of those types. Normally what you would have to do is to make a deque or vector of pointers of the base class type and then allocate each object dynamically with 'new' and store the...
5
1737
by: meLlamanJefe | last post by:
I have written a Queue class for our use that stores pointers to what I call RequestObjects. RequestObjects are a base class from which other types inherit and this allows the queue (or deque in this case) to hold values of different types. When popping values off the deque, the values are then typecasted back to their useful derived type. So far the class has worked well except with strings. When string values are typecasted back to be read off...
0
9487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7285
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.