« first day (404 days earlier)      last day (4560 days later) » 

2:00 PM
why not?
 
the offset of the derived classes functions are supposed to be the same as those for the base class
 
B inherited from A
 
else how is any code calling the base class supposed to find it?
 
@DeadMG isn't it? the same in this case?
 
B's M1 needs to be in the same place as A's M1, because no code taking an A can find offsets other than those specified in A's vtable
 
2:00 PM
are the Address fields supposed to be the addresses of the actual functions?
 
oh my mistake
 
It is in the same place
 
@DeadMG It's at offset 0 in both though
 
only different address
@jalf Yes
 
so yeah, that's how it'd normally be done for single inheritance
 
2:01 PM
Think of offset as index
bad choice of names
 
yeah, I just misread
 
index is fine. I think he just got confused by the address column
because your addresses are so low, they look like offsets
not often you see a function stored at address 0x1;)
 
So the problem will arise when you have multiple inheritance, since then you have A , B both having offset (index) starting at 0 for their methods
 
@ManofOneWay that is not a problem, because you know when calling the function which vtable to look into
you know that "I'm calling a virtual function first defined in A, so I'll look in my A::vtable
 
That's a problem if you are a C which inherits from A and B
 
2:03 PM
No it's not, because the compiler knows where the functions are defined
it knows whether you are overriding a function from A or B
 
But the vtable for C
 
C doesn't need one, unless it defines a new virtual function
 
or overrides a function from B
or from A ;p
 
The problem is which one should of A and B should start at offset 0 in C's vtable
3 0x0012 M3 : B should be M4: C
 
that's why you need to have two vtables
because they both need to start at offset 0
and in addition, the pointer casting won't work- you need thunks to offset the pointer
 
2:09 PM
If you're here later today I want to discuss this more, I need to go to class now and teach Java, horrible =/
brb
 
@DeadMG no, it can do that by writing into A's/B's vtable
It's not the derived class that should have a vtable, it's the base class where the vtable was first defined
 
what, so that A instances call C overrides when you make an A value?
 
oh sorry, make that vptr, not vtable
 
indeed
only in multiple virtual inheritance do you need more than one vptr for each base, I believe
 
@DeadMG yeah
 
2:21 PM
i wonder if it's possible for you folks to see the draft of next blog article?
 
Page not found
 
@EtiennedeMartel you win
 
any way i can provide a preview without posting -- on Wordpress blog?
 
@awoodland Yay!
 
2:24 PM
yep
 
Then I can go out for dinner and come back and incorporate all the suggestions and fix all the erors! <g>
 
I wonder how many genuine STL versions there are. All sources I checked today at least partially had a Copyright (c) 1994 Hewlett-Packard Companyinside :-)
 
those all have them from the very original STL source
 
From the book?
 
-3
Q: What prints this code? It it compiler dependent?

NarekWhat prints this code? Why? It it compiler dependent? int t=0; std::cout << t++ + ++t - t-- << std::endl;

Finally. I thought everyone had gotten this out of their systems, but it seems we have a comeback.
 
2:34 PM
Well, I still wonder, I would ask a Question How many genuine STL implementations are there? but I feel this would be closed as "not a real question" :-)
 
they changed the user page
 
@Martin there are a few. But it depends on exactly what you mean
the standard library != STL
I suspect there's only one STL implementation
 
not to mention STL derivate libraries, like D's
 
but several standard library implementations have their own STL
 
sbi
@KerrekSB I'd rather this wasn't closed as NaRQ. That is a real question, but it's a dupe. At least @DeadMG should have known about the FAQ lying around, and should have closed it as a dupe.
 
2:39 PM
you know, it lists everyone who voted to close, regardless of the reason, right?
 
sbi
@DeadMG I know (I'm listed as voting for NaRQ, too, after all), but when I voted this already had four votes, and none of them as a dupe.
 
ah, that's true, I did indeed vote for NaRQ
unfortunately, I'm currently streaming Starcraft 2 and can't spare too much attention on my other screen :P
 
@sbi there's probably enough of us here to re-open and re-close as a dupe. Not sure if that would be frowned upon though
 
@jalf - I wonder how many. STLPort != Dinkumware != Apache .... hmmm ... I'm too lazy to check all the source bases :-)
 
there's a libc++ one, as well
 
sbi
2:49 PM
@awoodland It needs another four votes, and it needs them fast, before the third close-vote hits.
 
I think it should just be deleted
the question title and tags aren't very searchable
 
sbi
@DeadMG None of the ++i+i++ questions are searchable. I don't think that's a reason to delete them, though.
 
I dunno, the FAQ must be named something like "Increment expression order"
I think they should be deleted because there's no reason to keep the question- it can't be followed to the FAQ entry because there's no way to find it
it's just noise
 
sbi
I think this could safely be deleted, but I don't like it being closed for the wrong reason.
Call me anal, but this is the C++ room, after all.
 
fair enough
 
2:53 PM
@DeadMG sure there is. Someone might have bookmarked it. Someone might find it through a random google search
there's no harm in having some duplicate questions on SO
DRY is a fine principle when programming, but less so when you're trying to store information for people to find and use
 
sbi
Too late, it just got closed.
 
sure, technically, someone could have bookmarked it, but that's really quite unlikely, and the same for random google search
 
sbi
Well, not too late. I voted to undelete. :) @jalf, @awoodland, this needs to more votes.
 
@DeadMG but what is the reason for deleting?
just satisfying the anal tendencies to "remove anything I can't see a need for"?
 
nah, I can usually tell those apart
it's an ++i + i++ question, it's the scum of the virtual earth, just let it die
 
sbi
3:00 PM
It's got two undelete votes now, and I have flagged for a moderator to step in.
 
@DeadMG you still haven't given a reason why
 
well, the question holds absolutely no value in any form whatsoever
 
sbi
Undeleted now.
 
So why was it asked?
And who are you to decide whether a question holds value?
 
sbi
We need undelete votes in order to properly delet it as a dupe.
 
3:01 PM
How about letting the person who asked the question decide whether it holds value?
 
how about asking him to read the FAQ and search the site first?
 
how about just leaving their question alone?
 
in which case he'd probably have found the FAQ entry we have on this topic?
 
you don't have to answer it
As long as people ask the question, it's clearly because they want the answer, and they didn't find a satisfactory answer to it
 
sbi
@DeadMG If for no other reason, then because these are often asked, but hard to find. This question could be another gateway to the excellent FAQ on the matter.
 
3:02 PM
sure, but nor do we allow people to ask the same question a hundred times
 
That might be because the existing answers aren't good enough, or because they're too hard to find, or something else, but bottom line is that someone wants an answer, and so it seems fair enough to allow them to ask the goddamn questiohn
 
he probably didn't find the answer just because he didn't look
 
@DeadMG er, yes we do
@DeadMG so?
 
sbi
@DeadMG That was done. The correct dupe was pointed out by me. And only by me.
 
well, if you don't look for the answer, then I have little sympathy for whatever happens to your question
@sbi We already have a hundred dupes. If they were being effective, we wouldn't still get the same question being asked.
 
sbi
3:03 PM
@RMartinhoFernandes I want to reopen this and properly close it as the dupe it is, instead of NaRQ.
 
I went to bed at 21:30, and woke up at 16. How the hell does that work.
 
@DeadMG so you're saying that because the existing duplicate questions don't eliminate the need for people to ask the question anew, we should delete the question wherever it pops up?
HOW DOES THAT MAKE ANY GODDAMN SENSE?
Iv'e got a better proposal:
 
no, I'm saying he should search the goddamn site and find the FAQ and hundred duplicates
 
PEOPLE WHO DON'T WANT TO ANSWER QUESTIONS ABOUT PROGRAMMING SHOULD JUST STAY THE FUCK OUT OF SO
13
@DeadMG Why?
 
uh
 
3:05 PM
seriously, do you read every FAQ you come across?
 
it's one of the more basic tenets of SO that people should look for questions and FAQs before asking questions?
 
everyone knows that FAQ's are pure garbage 99.9% of the time. Every goddamn website has one, and they're nearly always the same copy/pasted cookiecutter information
No one takes a FAQ seriously unless they know in advance that it's useful
 
I don't read virtually any of the FAQs, because I hardly ever ask questions, and they're usually too general for the actual problems I have
 
@DeadMG It's also one of the more basic tenets of SO that people, even newbies, should be able to get their question answered
 
sbi
@DeadMG Didn't you just say yourself that this is hard to search for? What's the problem in pointing this out?
 
3:06 PM
And that some duplicates are perfectly ok. That's also a basic tenet
@DeadMG oh, so you don't have to read them because they're too general for your problem. But others should read them, even though they think they're too general for their problem
 
there's a very big difference between "some" and "The volume we get with i++ + ++i"
i++ + ++i is a very general problem
 
sbi
I suggest you calm down, @jalf, it's only the puppy. Reasoning will only get you so far.
 
How about this: you leave the question alone, until you've read up on EVERY FAQ you've ever come across on any website anywhere?
 
"How do I workaround this compiler bug?" is likely a pretty specific problem
 
@DeadMG and how do you know that it's a general problem, unless you already have the answer?
 
sbi
3:08 PM
One more voted needed for reopening.
 
well, the only relevant part of the question is the pair of increments
 
SO is supposed to be for the people asking questions. The ones who don't already know the answer to their question, the ones who don't know that there's a little self-nominated elite who hangs around here and has nothing better to do than put a "FAQ" stamp on questions they consider important
 
whereas if you have a compiler bug, it might be caused by pretty much any section of code
 
@DeadMG many people who ask this question assume it's a compiler bug, because it looks like one: "my code gets evaluated differently than I expect"
 
there's a big difference between "self-nominated elite" and "people who can google the problem text"
 
3:10 PM
yeah, only the former group are complete assholes
 
which does, indeed, yield a relevant answer as the second result
not the tenth or hundredth
 
Unless you know the answer in advance, i++ + ++i looks like a very concrete and specific question, and there's little reason to suspect that it has been asked hundreds of times in advance, or that it exists in a FAQ somewhere
 
sbi
Well, I gotta go. I trust that you guys will close the question as a dupe once it is reopened. Still one vote short. (@Cat, could you?)
 
especially when the term is nearly impossible to search for
 
@sbi Done.
 
3:13 PM
you can google "i++ + ++i" and get the question
 
@sbi just 2 votes on the dupe close now
 
3:27 PM
ok, I have a funny compiler error
> >c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1763) : error C2375: 'listen' : redefinition; different linkage
I'm mixing C and C++, so not sure if that makes a difference
using VC2008
do I have to set some linker options?
 
user784668
@TonyTheLion: don't listen, then.
 
you have to declare c functions as extern "C" in C++
 
@TonyTheLion it's not an extern "C" vs not exten "C" thing is it?
 
@awoodland not sure, where would I find that out?
@AlfPSteinbach right, but this file is included is a windows header
 
@TonyTheLion I'd search for all definitions of listen in your project
 
3:31 PM
hmmm it has this in front of the function WINSOCK_API_LINKAGE
 
Can anyone recommend a commenting style guide?
 
reproduce the problem in small set of files
 
@Raynos what does Indian Hill have to say on it?
(or rather one of the modern derivatives)
 
Oh FFS, 40 minutes and Firefox is already barely working. What the hell is happening.
 
user784668
3:41 PM
@CatPlusPlus it's normal Firefox's behavior.
 
No, it's not.
 
user784668
Ah, right.
 
2
Q: Add a close-with-prejudice option for questions available to 50K+ users

tvanfossonWith one click I'd like to vote to close as "Not a real question", cast a down vote, pre-register a delete vote, and, if possible, send a robot to dope-slap the OP when a really inane, clearly contrived, meaningless question is asked by someone with more than 200 rep (who should clearly know bett...

 
27
A: A new imaginary number? $x^c = -x$

Henning MakholmRobert's answer tells you correctly how to find, given an $x$, a complex $c$ such that $x^c=-x$. However, it is worth pointing out that you cannot find a single $c$ such $x^c=-x$ will hold for every $x$. There's no existing number that achieves this, and if you try to extend the number system by...

 
@awoodland (discussing exactly that question that got NARQd instead of closed as a duplicate)
 
3:44 PM
: first.
 
@CatPlusPlus so it is - I wondered if I could force it to let me reply to myself :)
 
@awoodland ...
 
@CatPlusPlus You can even force it to reply to future message.
 
:1946221 no way?
 
i was look for the c/c++ equivelants of java's javadoc and .NET's xml documentation
 
3:45 PM
If you guess the ID, it will turn into a link for you, but if you edit, it will show for everyone.
 
people may think I've flipped if I keep replying to myself
 
> While we're speaking from nuking from orbit...how about paying 500 rep for a nuke and directly destroy questions? ;)
 
I'd pay 5000 for nuking all silly benchmarks.
Let's see if turning TST off makes Firefox happier.
 
user784668
I'd pay ∞ for nuking all silly proposals for nuking anything.
2
 
3:50 PM
Woah, I completely forgot how original tab bar looks like.
Now all the chat content is where tabs were. Feels weird.
 
Thanks
 
Hm, maybe now Vimperator's hints will work with tabs.
 
What hints?
I just press b and type stuff about where I want to go.
 
Als
shit i feel sick :(
 
cpx
@Raynos I'm currently reading this book. I believe its in chapter 4.
 
Als
3:55 PM
Anyone noticed they changed the profile page layout.
 
I have 156 tabs open. :F
 
Als
@CatPlusPlus: Do you rememeber the 1st?
and why you opened it?
 
@Als It's been like that on meta for a while.
 
Cat Plus Cat = Cat[2];
 
Als
@RMartinhoFernandes: I see, didn't notice, this layout looks better though ..my thought.
 
3:58 PM
@Als I wish if they were going to pack that much information in they'd make it look better on widescreen monitors though
I posted that on the feedback Q on it on meta and it got heavily downvoted
 
Als
@awoodland: Because most people don't have widescreens perhaps. It looks good on my normal sized screen
 
people
now i do have an issue
 
widescreen is more common now, I'm pretty sure
 
It looks good (obviously subjective) on my 16:10 screen.
 
what I really want is something that works on both
 
4:00 PM
i got around my problem but im wondering why does it happen
 
Als
din din time....will be back later.
 
but it doesn't look that bad on 1080p
 
@RMartinhoFernandes it's got huge blank white space around it at 1920x1200
 
Try to find a new non-16:9/16:10 LCD monitor.
 
the 1024 width minimum is annoying too
because I usually have 1 window maximised or two windows side by side
 
4:02 PM
if i have a function like this:
char* mycppfunc(char* data)
{
char something[512]={0};
sprintf(something,"%s mystuff",data);
return something;
}
i find that this is not thread-safe!
i mean, the function is not thread safe..
 
user784668
@CatPlusPlus What for? Don't you know that the older the monitor is, the better it is for your eyes?
 
@Tenev looks alright for C, but I'd use snprintf
 
Gosh sprintf? What about some C++?
 
@Tenev it's perfectly thread safe, but return something; is UB if anybody uses it
 
i get a compiler warning - local variable returned
 
4:03 PM
240
Q: Can a local variable's memory be accessed outside its scope?

Avrahamshuk Possible Duplicate: Returning the address of local or temporary variable I have the following code. int * foo() { int a = 5; return &a; } int main() { int* p = foo(); cout << *p; *p = 8; cout << *p; } And the code is just running with no runtim...

 
and, if i got 2 threads, sometimes the returned statement is empty...
 
if you made it static then it would be legal, but not thread safe
 
user784668
@RMartinhoFernandes (@everyone, really) sprintf is okay in C++. Maybe it's not considered a good style to use it, but it's still okay.
 
no
no, it most definitely is not ok
buffer overrun waiting to happen? extensibility?
doesn't take C++ types?
 
user784668
It has some problems, but it's okay (as in legal).
 
4:05 PM
sprintf is a steaming pile of manure
legal != ok
I could legally make virtually every variable global
 
@Fanael By that logic CRT death machines are the best monitors ever.
 
but that wouldn't make doing it OK
 
@awoodland sometimes the %s is empty, i still cannot understand why..
 
user784668
@CatPlusPlus of course they are, you didn't know that?!?
 
and by "some" problems, you mean "Every problem I could possibly think of"?
 
4:07 PM
Right.
 
@Fanael I don't care if it compiles. I want the freaking buffer overrun issues to be a thing of the past.
Because they are.
Except some people are stuck in the past.
 
user784668
Maybe someone wants to crash her app due to a buffer overflow, what then? sprintf would be one of the best functions to use, losing probably only to gets.
 
sprintf is not type-safe.
 
easier to just do that manually
 
sprintf is not extensible.
 
4:10 PM
sprintf is not any kind of safe, let alone type-safe
 
user784668
@CatPlusPlus not that that's much different from the rest of C++. Nothing in C++ is really type-safe.
 
Right.
 
user784668
It's just that some things are less unsafe than others.
 
@CatPlusPlus Hey, that's my line.
 
user784668
4:14 PM
Oh well. I was wondering why the music is playing much louder than it usually does.
 
uh
I'm pretty sure that almost everything that's OK to use in C++ is really type-safe
 
user784668
Guess what? I accidentally left the volume bar at 100%.
 
what's your definition of "not-really" type-safe?
 
user784668
@DeadMG something is "type-safe" (or not-really-type-safe, if you like) if it pretends to be type-safe, but an accidental bug in a completely different part of code has the ability to turn all the type safety into ashes (cf. undefined behavior). I.O.W., everything in C++.
 
the fact that you can dereference NULL somewhere is irrelevant to the type system
 
4:20 PM
how did this answer: stackoverflow.com/q/8258655/168175 get three upvotes?
 
type-safe code only means that the constraints of the type system are not violated
std::vector<int> x; std::cout << x.front(); is UB but still perfectly type-safe
 
user784668
@DeadMG it actually is, because it can mean e.g. that some int is treated as if it were a float, effectively violating the guarantee that it's an int.
 
not legally
that violates strict aliasing
 
user784668
@DeadMG that's why it's an UB, right?
 
well, it's illegal, what more do you want to do about it?
 
4:22 PM
So today at the job we're releasing a new version of our app. I'm not involved in this and I'm happily hacking on the next version of the app in a different branch. Suddenly it turns out one of my commits is leading to a crash in the app that is to released. (I hate svn externals.)
 
plus
that's not in the realm of OK code
that's in the realm of gets/sprintf code
which no C++ programmer would actually accept as C++ code
 
user784668
@DeadMG if writing desktop apps or something like that, you're right, and I agree. If writing some very low-level system code, where it's you versus the hardware, it could happen.
 
firstly
that's unlikely because most of it would be in registers, so you won't get much milage out of type-punning pointers
but more relevantly, there are plenty of type-safe ways to type-pun an object
 
Metal coding is insane on its own, really.
 
user784668
@DeadMG I'm not talking about type-punning here. I'm talking about the possibility of a pointer getting an unexpected value due to a bug (i.e. the memory gets overwritten somehow), and then the program unknowingly breaking the type system.
 
4:34 PM
right
so you wrote a bug, and you want me to have sympathy?
that's how it works- you write bugs, then stupid things happen
 
user784668
Exactly!
 
next time, don't write bugs
the problem here has nothing to do with the pointer, or type-safety
the problem is that you wrote a bug
 
Als
@DeadMG: Pup you seem to be very excited today
Whats the matter?
All fine, I hope
 
aaah
 
user784668
It has much to do with type safety. If there were any kind of runtime type safety, the bug couldn't do any harm in the first place, because an exception would be thrown, program would be aborted, etc (but in any case the behavior would be consistent and well defined).
 
4:37 PM
the usual
well, if you want to cripple your program's performance irrevocably by checking everything, then knock yourself out
however, everyone else will just not make idiotic mistakes that the compiler can prevent you from making anyway
the simple fact is that you cannot assign a pointer to random memory values unless you're already subverting the type system
you have to break C++ type safety, knowingly, and explicitly, before you can do that
and when you do it, it's your own dumb fault as to what happens if you get it wrong
 
user784668
@DeadMG there are people who don't mind the performance drop and are happily writing their code in e.g. C#.
 
Anyway, there is a typesafe subset of C++. It's simply not true that nothing is type-safe in C++.
 
sure
but what do I care? This is the C++ room
and we were discussing C++
 
user784668
@DeadMG well, you can. Think about it. But then again, this wouldn't be considered good style.
 
and the fact is, you must explicitly subvert the type system
and when you do, then the results, good or bad, are on your own head
 
Als
4:43 PM
hmm war of words...
 
oh yeah, sorry
you must explicitly subvert the type system in C++
not if you go back and use sprintf, for example
in which case, again, what happens is your own fault
or the fault of your C++, really C, education
 
hey guys
is a array[10] same as array[5][2]?
 
no
 
i mean
 
Als
@coolbartek: What made you think so?
 
4:48 PM
if i make an array [5][2]
than is my object in array [4][1] same as array[9]?
 
user784668
@DeadMG Foo* p = new Foo; Foo* q = p; delete p; Bar* r = new Bar; /* assume that the returned address is the same as before */ q->Fooize(); /* now what? */ Didn't subvert the type system, yet still it's the same thing. Note that I'm not saying anywhere it's a good style (in fact, is about as bad as one can get), all I'm saying is that it could happen.
 
so the only other way to go through a multi dim array is by pointers?
 
Als
@coolbartek: May I suggest this:
 
What are you trying to do?
 
Als
4:49 PM
58
Q: How do I use arrays in C++?

FredOverflowC++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n> since C++11), so the need for arrays does not arise quite as often as it does in C. However, whe...

 
uh
raw new and delete practically is subverting the type system
how is that any different to malloc and free?
type system dynamic allocation is shared_ptr and unique_ptr
 
so they are the same :)
 
both of which would fail to compile your example, if T* were to be replaced
and neither of which would leak
 
"This means that you can take multi-dimensional arrays and treat them as large, one-dimensional arrays"
 
unlike your r, which would leak if you called an exception function
 
4:52 PM
thanks again
 
user784668
I know, I know, I really know. "Note that I'm not saying anywhere it's a good style (in fact, is about as bad as one can get), all I'm saying is that it could happen."
 
yes
 
Als
@coolbartek: I would suggest reading(studying) that Faq entry than just breezing through it.
 
but it'd also be your own dumb fault for not using a smart pointer
so I'm still not sympathetic in the slightest
 
Still far from nothing is type-safe. Providing an example is not enough for that.
 
4:55 PM
I'm using some C functions from a .h and .c file in my C++ app, however the linker says it's a "unresolved external symbol"
I have no idea what is wrong
I've included the .h file obviously
 
Does it use extern "C"?
 
these C files are inside my project
 
If not, the symbol names are mangled when used in C++.
 
Als
linkage specification!
 
@CatPlusPlus what? the function calls?
 
4:56 PM
The header should be wrapped in extern "C" block.
 
Als
@CatPlusPlus: Darn you always fast!
 
user784668
@DeadMG: well, I'd agree with you right away, if there weren't that many poor C++ programmers. The reality is unfortunately way more sad.
 
are you all insane
 
poor C++ programmers is not the fault of C++
 
just wondering, am i the only maniac here
 
4:58 PM
it's the fault of whoever taught them to be that way, or their own inadequate self-teaching
 
It's a bit of C++ fault.
 
@DeadMG The fact that C++ sucks also helps.
 
sure
 
@RMartinhoFernandes what does not suck?
 
4:59 PM
but it doesn't suck in the way exemplified above :P
 
@Tenev Haskell!
 
Bananas.
 
Wait, I can break type-safety in gasp Haskell.
 

« first day (404 days earlier)      last day (4560 days later) »