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 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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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?
|
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
>...
|
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...
|
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...
|
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;
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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 ...
| |