VC++ 2010

Pages: 12
Anyone tried it, yet? Uncharacteristically for Microsoft, they've broken a few common expressions involving pointers. I was trying compiling some old code yesterday (that of course I had previously compiled with both VC++ 9.0 and GCC) and got an error on this line:
1
2
3
//std::vector<T *> buffer;
//size_t a;
buffer.insert(buffer.begin()+a+1,0); //error C2440: 'initializing' : cannot convert from 'int' to 'T *' 
Maybe it's just me, but I really don't think I need the explicit cast, there. Or nullptr, for that matter.

Oddly enough, push_back() works as expected.
did you try it with NULL or ((void*)0) ?...

didnĀ“t test the NULL-pointer till now... gonna do it, later and report back to you...
NULL expands to 0. Implicitly casting 'void *' to non-'void *' is illegal, so that wouldn't compile even on 9.0.
we are both talking about the second parameter, arent we? (to make sure i understood you correctly)...
Yes.
I thought NULL expanded to ((void*)0), or is that just C?
Yes.

1
2
3
4
5
6
7
8
//stddef.h (27):
#ifndef NULL
#ifdef __cplusplus
#define NULL    0
#else
#define NULL    ((void *)0)
#endif
#endif 
Last edited on
did you try the nullptr, too?...
Try an explicit cast?
chrisname wrote:
Try an explicit cast?


helios wrote:
but I really don't think I need the explicit cast there.


But that's...odd. I think they did break it...guess I'm not going to upgrade then. >_>
http://msdn.microsoft.com/en-us/library/sy5tsf8z%28VS.100%29.aspx
C2440 can occur as the result of conformance and update work that was done in the Standard C++ Library.
Apparently it's not accidental. I still think it's odd that the explicit cast is required.
Oh, well. It's not like it costs anything.
<richard stallman>
Except your freedom!
</richard stallman>
<Bill Gates>
Accept your freedom!
</Bill Gates>
<Steve Jobs>
Master of brainwashing people into thinking buying a computer is joining a social movement, away!
</Steve Jobs>
If you're not using any clr / managed stuff : why would you ever on earth prefer compiling with VC++ instead of mingw (gcc) ?
Last edited on
closed account (z05DSL3A)
<Ada Lovelace>
Call that an algorithm? This is an algorithm!
</Ada Lovelace>
If you're not using any clr / managed stuff : why would you ever on earth prefer compiling with VC++ instead of mingw (gcc) ?
At the compiler level, there's indeed very little difference. The debugger, however, is superior to anything GNU has to offer. To put it bluntly, gdb sucks balls.
Older versions of MinGW used to have conformance problems even bigger than the one I mentioned above and several bugs. Having to explicitly cast a zero is nothing compared to swprintf() taking the wrong number of parameters, or the compiler producing wrong code under specific circumstances or sometimes even crashing non-deterministically (both have happened to me with MinGW 3.x). At least with VC++ I have a little more certainty that if the input is correct the output will be correct.
im still interested wether it work when you use vec.insert(vec.begin()*x+1, nullptr); ???
I did say it worked on my first post. That's not really relevant, though, because I'm working with C++98.
Does anyone else have this issue where a new project/solution won't "start without debugging"? I usually do that so the console window stays open, but when I click "start without debugging," it just goes through as if it's only debugging and closes the window down.

I know there are a number of workarounds, but I am curious as to why the start without debugging won't work. Anyone else have this issue?
Pages: 12