473,466 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Re: Unexpected compiler behavior relating to size_t and boost -Visual Studio 2005.

Here is the smallest code I could come up with to reproduce the
behavior:

#include <vector>
#include <functional>
#include <boost/function.hpp>

template< class T >
void test()
{
typedef std::vector< T TItems;
typedef boost::function< bool (T, T) TCompFn;
typedef std::vector< std::size_t TSizes;

TItems data;
TCompFn fn = TCompFn( std::greater< T >() );
fn( data.front(), data.front() ); // NOTE: data is empty - will
cause a runtime error if run

}

int main()
{
test< int >();
test< unsigned >();

}
I was able to reproduce the warning with an even smaller snippet of
code:

#include <vector>
#include <functional>
#include <boost/function.hpp>

int main()
{
std::vector< std::size_t sizes;
std::vector< unsigned data;

boost::function< bool (unsigned, unsigned) fn = std::greater<
unsigned >();
fn( data.front(), 10 );
}

The warning goes away if I comment out the line "std::vector<
std::size_t sizes;". This behavior baffles me. Any insight would
again be appreciated.

Thanks,
Matt
Jul 13 '08 #1
3 2009
Unknownmat wrote:
I was able to reproduce the warning with an even smaller snippet of
code:

#include <vector>
#include <functional>
#include <boost/function.hpp>

int main()
{
std::vector< std::size_t sizes;
std::vector< unsigned data;

boost::function< bool (unsigned, unsigned) fn = std::greater<
unsigned >();
fn( data.front(), 10 );
}

The warning goes away if I comment out the line "std::vector<
std::size_t sizes;". This behavior baffles me. Any insight would
again be appreciated.
I cannot reproduce C4267 myself with MSVC 8.0 and Boost 1.35.0, not even
with /Wall. I suggest you try microsoft.public.vc.language (which is the
proper place to ask VC-specific questions, anyway).
--
Christian Hackl
Jul 14 '08 #2
Thanks for the response - it wasn't clear to me that this was a MSVC
specific bug. Perhaps I shouldn't have added that to the title,
except that I knew it would come up (and rightfully so, apparently).

Curiously, are you using VS 2005 with SP1? I've been able to
reproduce this fairly consistently on multiple computers. I'm a bit
surprised that you say that you cannot reproduce it.

Thanks,
Matt

Christian Hackl wrote:
Unknownmat wrote:
I was able to reproduce the warning with an even smaller snippet of
code:

#include <vector>
#include <functional>
#include <boost/function.hpp>

int main()
{
std::vector< std::size_t sizes;
std::vector< unsigned data;

boost::function< bool (unsigned, unsigned) fn = std::greater<
unsigned >();
fn( data.front(), 10 );
}

The warning goes away if I comment out the line "std::vector<
std::size_t sizes;". This behavior baffles me. Any insight would
again be appreciated.

I cannot reproduce C4267 myself with MSVC 8.0 and Boost 1.35.0, not even
with /Wall. I suggest you try microsoft.public.vc.language (which is the
proper place to ask VC-specific questions, anyway).
--
Christian Hackl
Jul 14 '08 #3
On Jul 13, 3:42*pm, Unknownmat <unknown...@gmail.comwrote:
The warning goes away if I comment out the line "std::vector<
std::size_t sizes;". *This behavior baffles me. *Any insight would
again be appreciated.

Thanks,
Matt- Hide quoted text -

- Show quoted text -
In case anybody is interested - I figured out what's causing this
issue. Microsoft's "detect 64-bit portability issues" compiler option
causes both false-positives, and false-negatives, and interacts poorly
with templates. This is clearly one of those cases.

Turning off the "/Wp64" switch will eliminate this false warning.

Thanks for the help. Sorry for being OT.

Matt
Jul 14 '08 #4

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

Similar topics

11
by: spipyeah | last post by:
Is there a collection of C++ source files that can be used to test compiler compliancy by using really extreme language cases, making sure the standard library is complete, and other such things?
19
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
16
by: He Shiming | last post by:
Hi, I'm having a little bit of trouble regarding pointer casting in my program. I don't understand why the following two cases produce different results. Case 1: IInterface *pInterface = new...
7
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I saw cuj's conformance roundup, but the result is quite old. I think many people like me want to know newer c++ standard conformance test...
62
by: ashu | last post by:
hi look at this code include <stdio.h> int main(void) { int i,j=2; i=j++ * ++j * j++; printf("%d %d",i,j); return 0;
33
by: Geometer | last post by:
Hello, and good whatever daytime is at your place.. please can somebody tell me, what the standard behavior of strtok shall be, if it encounters two or more consecutive delimiters like in...
1
by: Alan Johnson | last post by:
From the standard 5.3.5/5: "If the object being deleted has incomplete class type at the point of deletion and the complete class has a non-trivial destructor or a deallocation function, the...
4
by: duffdevice | last post by:
Hi, I came across this unexpected behavior while working on something else. I am attempting to return a custom type by value from a global function. I have a trace in the custom class's copy...
6
by: JohnQ | last post by:
I like, non-copyable, non-assignable and, most often, non-default-constructable also, as a starting point for class design: class SomeClass { SomeClass(); // disallow default construction...
10
by: arpit | last post by:
Hi All, I had a C application. Which sometimes gives correct result and some time worng or no result under the same env. Can anyone tell me what are the possible reasons for it like memory or...
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
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.