« first day (326 days earlier)      last day (4622 days later) » 

5:00 PM
"Slightly".
 
well, he basically would like the users to initiate make every time they upgrade the program
I don't think re-building the source every time is a good plan - why not just distribute the binary?
 
Because, something about big.
Like, there's too little bandwidth and disk space nowadays.
 
12
Q: Will using `goto` leak variables?

Tomalak Geret'kalIs it true that goto jumps across bits of code without calling destructors and things? e.g. void f() { int x = 0; goto lol; } int main() { f(); lol: return 0; } Won't x be leaked?

What is going on here?
 
@RobertHarvey rep harvesting
 
Are you guys done with that conversation in the comments? Because I would like to clean it up now.
 
5:06 PM
wait.. he asked and then answered his own question?
I guess future-proofing the site
 
That's perfectly acceptable.
 
@RobertHarvey u're the 2nd moderator descending on this group in 2 days, lol
 
No surprise there. :P
 
@RobertHarvey Yes, just strange I guess (I only see one other answer and it was deleted)
 
@RobertHarvey There's been a long conversation between David, David, David, and Tomalak.
Neither of them has been in this room recently.
 
5:07 PM
Any resolution?
 
How could we know?
 
what's wrong with the comments?
It would be nice if a mod could roll them up so it wasn't such a clutter
 
The first one is the only one that is relevant to the question.
 
and it provided a link to say "View x comments"
 
Mods do have access to that (a deleted comments window), but nobody else does.
 
5:10 PM
I agree David's initial post should be deleted, Tomalak's reply should be deleted, Nawaz's reply looks good, Then Tomalak's 2nd reply to Nawaz is noise
so I wouldn't delete them all though
 
i basically disagree with altering history
 
I would have just edited the question to make it have a decent code example, but it would make a part of the answer meaningless, and, judging from the comments, it would most likely be rolled back.
 
deleting things changes context and alters history
 
it's old soviet regime mindset
very ungood
 
5:11 PM
Oh, please.
 
@AlfPSteinbach so you are against time travel?
 
Comments are meant to be transitory. If you have something valuable to say permanently, it should be in an answer.
 
no matter how honorable the motive (like cleaning up)
 
@AlfPSteinbach That's not soviet. That's IngSoc.
 
How 'bout I keep the first three?
 
5:12 PM
@RMartinhoFernandes +true
 
@RobertHarvey 3 plus Nawaz's
 
Oh, there's a negotiation going on!
 
Well at least you asked :)
 
You mean the sixth one? I think the point has already been made.
Alright, thanks for the feedback.
 
@RobertHarvey Yes, the sixth one.. I dunno if it was made until Tomalak acknowledged what Nawaz said in the 7th comment.
 
user457812
5:19 PM
I saw someone writing C in Word D:
 
user457812
Code, that is, not the letter C.
 
lol
I'm not sure what's more idiotic, coding C or coding in Word
 
But in Word you get to do syntax highlighting as you please!
Imagine all the flowery comments you can write!
 
yeah, you get syntax highlighting
manual
 
user457812
smacks DeadMG
 
user457812
5:22 PM
C is fun!
 
user457812
It's old and pointless to use for most purposes, but fun nonetheless
 
@nil You maybe saw JScript programming. Word supports JScript and VBA. JScript is a curly brackets language.
 
As in, "fun to make fun of"?
 
user457812
Masochism is a good thing.
 
5:25 PM
Yeah, so says the masochist.
 
user457812
@Alf No, this was in a C programming class. He was writing the usual "hello, world" stuff.
 
if by fun you mean worthless, I fully agree
 
Als
5:36 PM
Anyone, how is this correct?
0
Q: NULL passed directly to a function expecting a const reference parameter (VC++ 4.2)

DennisI am looking at something that I discovered in an old code base, and I am pretty confused. Here is a function definition: void vUpdateSequenceDetailsAndIncrement( const CallEvent& roCPEvent, const CallInfo& roCallInfo, BOOL bCreationEvent); Here it ...

hmm...anyone?
 
there's an accepted answer
read it, it says the answer, funnily enough
and VC++ 4.x? how many billion decades ago was that released?
 
billion decades?
 
Als
@DeadMG: You can definitely pass a NULL to an function taking an reference argument
 
I thought that was a no no
 
@Als Whoah whoah your answer is seriously off there
 
Als
5:38 PM
@LucDanton: how?
 
From what we're told there's nothing invalid going on.
 
Als
@LucDanton: I though I am missing something, and so
 
the code could legally construct a temporary of type CallInfo from zero
 
@Als Implicit conversion from int to that type.
 
Als
@LucDanton: You would need an conversion function for that wont you?
for that to happen
 
5:40 PM
@Als: Or implicit constructor for CallInfo
 
@Als struct silly_explicit_keyword { silly_explicit_keyword(int) {} };
Also works for pointer types.
(Depending on implementation etc.)
 
Als
@DeadMG: There is no temporary generated there, Its call by reference?
 
Reference to const.
Anyway, suggesting that you can get from NULL to an invalid reference is not a sensible thing to do IMO.
 
Als
@LucDanton: ??
 
Because you can't.
 
Als
5:43 PM
@LucDanton: You cant have a null reference, is that the argument?
 
Yes.
 
Als
What if you have an pointer that points to null, you won't know that until run time, If that is used to an reference, then?
 
UB
 
Als
Yeah, thats an Invalid Reference
 
No, that's an invalid program.
 
Als
5:45 PM
Thats referred to as an Invalid Reference
 
So?
 
Als
So technically, there Reference being NULL is a possibility, though that would cause an Invalid reference
 
@Als It is mainly about a clean separation between CORRECT and INCORRECT. Since compilers can't reasonably check this it's just a convention. But it is a powerful one, because when you have nullpointer it might be valid, but when or if you have null-reference, then you absolutely know that there is a bug, an error.
 
The program is invalid due to the silly dereferencing, references have nothing to do with it.
 
Als
My answer states that fact
 
5:46 PM
@Als That's not 'C++ technically', that's 'implementation technically'.
 
hm. i often find that i need classes like this:
        class ScopedKey
        {
        private:
            ScopedKey( ScopedKey const& );                  // No such.
            ScopedKey& operator=( ScopedKey const& );       // No such.

            HKEY    value_;

        public:
            HKEY value() const { return value_; }
            operator HKEY () const { return value(); }

            ScopedKey( HKEY key )
                : value_( key )
            {}

            ScopedKey( ScopedKey&& other )
                : value_( other.value_ )
It's very trivial.
In C++98 there was no good way except maybe using a scopeguard.
 
Als
@LucDanton: And since no compiler can convincingly check for that, its the same for all
 
Is the conversion operator implemented here?
 
Although i did try my hand at creating a simple Ownership class
 
@Als What?
 
5:48 PM
Is there a simpler, general thing for C++11?
 
To transform a type into a type that gets to a default state when moved from?
Or for single-ownership?
 
Ownership. The transfer thing is just to allow ordinary = initialization.
 
Als
@LucDanton: So it is possible to have an reference that is NULL, just using that reference causes an UB. Do we disagree?
And by possible I mean , in ways compilers cannot detect it
 
std::unique_ptr can work for some, not in this case I think though.
@Als Yes.
Dereferencing causes UB. References have nothing to do with that.
 
@Als "possible" has two meanings. In practice possible. In the formal not possible.
 
5:50 PM
I think that even creating it is UB
 
Als
@LucDanton: So, how does the answer be very off...Not that I am being adamant that it cannot be, it can very well be, just trying to understand here.
@AlfPSteinbach: Not possible as per the standard? is what you mean to say
 
@Als The language has no notion of null references. Implementations may exhibit so called null references in invalid programs. Even without those references the program would already be invalid.
 
Als
@LucDanton: If you would never dereference?
still?
 
@Als No, if you had the same semantics but without using references explicitly.
So, pointers really.
 
Als
@LucDanton: So its just another program which has an UB, when you use that reference, not that the program is invalid.
 
5:54 PM
From the code the OP has given us, if this truly was a situation with UB then the class involved would be pathological.
 
Als
and that is an UB, because the reference was NULL, though it cannot be still it can in some ways.
 
@Als I don't understand that.
 
Als
@LucDanton: Reference can be NULL, but if a reference is NULL, using it is an UB
 
No.
 
Als
fair enough?
 
5:55 PM
Can't have a null reference in a valid program.
You can't get there.
It's not a matter of 'you used a null reference, everything goes bad'
It's 'by the time you have a null reference you screwed up'
 
Als
@LucDanton: We just agreed that it is not an UB unless you actually use such an invalid reference(null one)
 
@Als I don't remember agreeing to that.
 
I also didn't agree to that
the only way the language semantics might even possibly allow for it is de-referencing a NULL pointer, which is instantly UB
 
Als
8 mins ago, by Als
@LucDanton: So it is possible to have an reference that is NULL, just using that reference causes an UB. Do we disagree?
7 mins ago, by Luc Danton
@Als Yes.
 
@DeadMG You also can have zero-initialized references.
 
5:57 PM
so yes, he does disagree
 
"Yes, we disagree."
Should have made that clearer, sorry.
 
Als
uhm ok
Nah my bad, okay, you didn't agree
 
Well I could have been answering "Yes, it's possible".
 
Als
So is the excerpt i posted from wikipedia off?
Or i am interpreting it wrong way?
 
I suppose it is off. A bit hard to tell without context.
 
Als
6:01 PM
grr..it doesn't post the correct link :(
<http://en.wikipedia.org/wiki/Reference_(C%2B%2B)>
thats the link minus the < >
 
It mentions null references in terms of implementations, not of the language (although it makes a note of that).
Also, I believe this article is related to the Reference article, which is about the general CS concept of a reference.
The usual definition allows for null references.
 
Als
No it quotes specifically for C++.
 
At least I see that as a callback to that article.
@Als Well, yes?
 
Als
Pasting it here...
Thus, if you have a NULL pointer or a pointer pointing to an invalid location in memory, you will de facto have a reference that points to NULL or an invalid location. C++ purists would argue that, technically, dereferencing a NULL or invalid pointer leads to undefined behavior anyway, so this does not violate the assertions above that a reference cannot be null or point to arbitrary places in memory.
However, this ignores the fact that in this case, the underlying implementation simply performs an "assignment", and there is no access of the memory location involved,
 
'de facto'
 
Als
6:05 PM
so this initialization of the reference usually does not cause problems, and programmers must be aware of the possibility of a de facto "invalid" reference in a real program
 
'underlying implementation'
etc etc
The 'C++ purists would argue that, technically, ...' is the note I mentioned.
 
Als
But no implementation can actually check this so its across all the implementations actually?
 
Do we not read this the same way?
@Als Check what?
 
Als
Agreed, It talks from implementation and not standard
 
If it's the dereference, then they may.
 
Als
6:07 PM
But no implementation can actually check this so its across all the implementations actually.
 
@Als What is 'this'?
 
Als
@LucDanton: this pointer?
or in context of the text above
ah okay this ignores.....
 
When you say 'can check this', 'can actually check this'; what is 'this'?
i.e. what check are we speaking of here?
 
Als
@LucDanton: sorry should have been clearer: this = check that a reference can be null
at compile time
 
It's a real pointless thing to do.
It's much smarter to focus on dereferencing.
(But yes, that last one is a hard problem.)
 
Als
6:10 PM
The compiler checks for a null here: int &i = NULL;
at compile time
 
no, you're just trying to initialize a mutable reference from a temporary
 
Als
but it can't check if one uses a pointer which gets a value assigned at runtime(which might be NULL)
 
int& i = NULL; is not valid code.
Doesn't type check.
 
Als
Just to conclude @LucDanton, @DeadMG: Invalid reference(referencing a NULL) is an implementation of compilers, Standard does not allow reference to be NULL, and a code which even allows that to happen is ill-formed
 
Yes.
 
6:16 PM
absolutely
 
It's not just a waste of time to check references, it also lulls into a false sense of security. There's an example somewhere with dead code elimination.
 
Als
@LucDanton: Would be grateful, if you could dig out that example for me, whenever you have the time ofcourse.
 
Warning: Product may contain nuts.
 
Als
@LucDanton, @DeadMG: Thanks though for the clarifications.
 
Ah, not so much about C++ references than UB.
@Als Still, somewhat relevant. Just imagine that on the dereference line it's reference binding (e.g. int& ref = *P;) and it's the same.
 
6:23 PM
Blah.
 
Als
@LucDanton: Thanks
 
Watching the following.
Hardware does insane stuff to your code.
 
@RMartinhoFernandes Awe-induced statement? (I can't watch that right now.)
 
@LucDanton Yeah, I knew processors were super duper smart these days, but I didn't know lots of details.
 
The best course I had was about hardware/architecture. Some of it because the teacher is great, but also because the subject matter is interesting.
 
6:34 PM
@RMartinhoFernandes I saw that video, it's a very interesting video :)
@LucDanton I have some books about hardware architecture, haven't read much though
still trying to get my head around C++ :P
6
Q: Once upon a time, when > was faster than < ... Wait, what?

Armen TsirunyanI am reading a wonderful OpenGL tutorial. It's unbelievably great, trust me. The topic I am currently at is Z-buffer. Aside from explaining what's it all about, the author mentions that we can perform custom depth tests, such as GL_LESS, GL_ALWAYS, etc. He also explains that the actual meaning of...

 
lol
I +1ed just for the title.
 
6:50 PM
0
A: Function that polymorphically handles vector and hash_set

Tony The TigerA function template would allow you to make it more generic: template<typename T, typename Cont = std::vector<T> > void MyFunction(T t, Cont c); Here the default container would be std::vector<T>, but you could still change the container if you wanted to.

is it me or is Tomalak's comment a severe nitpick?
what do you think about my answer?
I'm sure there's mistake in there somewhere
 
@TonyTheTiger aren't they always?
 
@TonyTheTiger Was the comment removed?
 
can't stand him
 
@LucDanton not that I can see
 
So, comment to the question, not your answer?
 
6:55 PM
@LucDanton it's the comment on the question, that he is passing a pointer, not a vector
 
@TonyTheTiger Okay, I got confused.
 
but technically, he's passing a pointer to a vector<int>, but really, is that important?
I mean, the OP might be a newbie, and I don't think it matters
only a C++ nerd would be that nitpicky
 
Whatever, he's passing a vector (by pointer).
 
6:56 PM
It should be a reference anyway.
 
sometimes the nitpicking in C++ get's on my nerves
people take it too far, and will sometimes even downvote things, for a small minor thing
ughhhhh
 
I'm too lazy to fix my answer.
 
@TonyTheTiger you're in the Lion's den here
home of the pedants
 
@StackedCrooked I know
but I think it's even worse when answering questions on SO main
the smallest thing will be nitpicked, to the comma
 
here it's always pedantry with a social twist to it
makes it nicer
 
6:58 PM
yea indeed
I wondered if my answer to that question couldn't have been resolved using SFINAE
I mean, you could overload on wether the container has insert or push_back
no?
 
Yes (requires decltype).
 

« first day (326 days earlier)      last day (4622 days later) »