« first day (467 days earlier)      last day (4472 days later) » 

9:00 PM
hey robot
what was that command you used to pull the DNS for a domain?
 
@MrAnubis But when you assign a string you assign its value, not a reference to it.
@DeadMG dig?
I'm on Linux btw.
 
right
 
non object oriented templates still rocks
 
I'll google for an online utility or something then
 
@CaptainGiraffe how is that not true. C# references act as pointers. If you want to change what's assigned to C# reference, you have to pass it by reference. If you want to change what's contained in a C# value-type, you pass it by reference. In C++ if you want to change what's contained in a C++ object, you pass it by reference.
 
9:00 PM
@MrAnubis Still not the same thing. In C++, a string variable is an object that refers to dynamic memory internally, whereas in C#, a string variable refers to a string object that refers to dynamic memory internally. That's one more indirection.
 
If you're interested, it doesn't seem to be working.
No wait, bad me.
 
@FredOverflow C# concept of objects are like pointers to C++ concept of object.
 
@FredOverflow aah, Thanks for more clarification :)
 
@FredOverflow a string is an array, and arrays decay....
 
@DeadMG Ah, wait, for wide-language.com I get wide-language.com. 80 IN A 89.187.101.74
 
9:02 PM
@Xaade true they are all pointers but never mentioned as such
 
yeah, but www. doesn't seem to beworking
 
well I really don't like messing both lang'es concepts when I don't know both of them good :D
 
and Chrome automagically changes it, which is not so helpful
 
@Xaade What's relevant here is that C# and C++ have different definitions of what a variable is. In C#, variables refer to objects, whereas in C++, variables are objects.
 
@DeadMG Right, www produces nothing.
 
Xeo
9:02 PM
@DeadMG Nope, doesn't work
 
@Xaade A C++ string is not an array.
 
@FredOverflow also in c++ the stack rules hardcore.
 
I added another identical A-record for the "www" subdomain
 
dig is part of BIND tools.
 
give it about another billion decades to propagate..
 
9:03 PM
@CaptainGiraffe C++ has no notion of a stack ;)
 
Entries don't propagate, silly.
 
@FredOverflow sry raii
 
The changes to old ones aren't visible immediately because of cache TTL.
 
@CaptainGiraffe I <3 RAII
 
But non-existing answers aren't kept for very long in caches.
 
9:04 PM
@FredOverflow Yeah, which leads to why you never have problems with mutable value types, because everything IS a value-type (other than a pointer or reference). So if you want to modify anything in a method, you send it by reference, whereas in C# you get that for free with reference types, and have to send to by reference to modify it's "pointer". I prefer C++ way, because expectations remain the same. But because expectations change in C#, it's best to leave value-types as immutable
because most people can't figure out C# reference and value-types.
 
Also why having your own DNS cache is so nice.
 
@FredOverflow I <3 RAII too =)
 
@FredOverflow I was being sarcastic.
 
@Xaade What about iterators and smart pointers? ;)
 
@DeadMG seems to be up now.
I mean, the DNS, not the site.
 
9:06 PM
yeah
 
crap next question is what about auto...
 
Nice, now SDL fails assembling with "Error: unsupported for `movq'".
That's what clever optimising gets you.
 
int i = 0;
#define RAII ;
i <3 RAII
 
Xeo
@FredOverflow Err.. mumble mumble something..
 
I'm not gonna play this silly game. Oh wait...
 
9:08 PM
How is a semicolon nothing?
 
Xeo
lol
 
@FredOverflow those are "value-types" too if you look at the actual variable. If you want to modify a pointer's contents, you have to pass by reference. A smart pointer is a pointer-manager really, but it's still an object. So, when you pass by value you modify it's contents indirectly. If you were to modify what a smart pointer points to after passing it by value, you'd lose those changes.
 
I think there are simply too many definitions of "value type". Doesn't the C++ standard basically say that a value type is something that is copyable?
 
Xeo
It's interesting. With variadic templates, we actually get problems we didn't have before because pack expansion sucks.
 
Question, when you pass a smart-pointer by value, does it increase the reference count, since there's a new "pointer" to the object on the stack?
 
9:10 PM
Sure. That's why Scott Meyers and Herb Sutter suggest passing shared_ptrs by reference to const.
 
@FredOverflow It has that definition?
 
@Xeo So, you're saying new feature comes with new set of problems. Unbelievable. :P
Oh, now I'm missing DirectX headers.
This will be fun.
 
@FredOverflow is that a yes to increasing the reference count when copied?
 
No, it's a way to avoid increasing it.
 
Xeo
@CatPlusPlus Heh
 
9:11 PM
It's both!
 
I fail to see the point in taking a shared_ptr by reference.
If the function isn't going to take ownership, why not take a reference to the object?
 
@RMartinhoFernandes see 26.2 §1
 
I can see a smart pointer increasing it's reference count when passed by value, if it contained a static array of smart-pointer pointers, or a factory-warehouse. Then it would check when constructed if it's value has an entry, and then increase the reference count in the entry. Then when destructed, it could decrease the count.
 
Wait, what?
Are you trolling?
 
@RMartinhoFernandes me?
 
9:14 PM
@Xaade Copying a shared_ptr increases the reference count, and passing by value makes a copy (unless you pass an rvalue).
 
Sometimes you do...
 
No.... I'm guaranteeing an correct reference count upon copying a smart pointer.
 
You don't need a static array anywhere.
 
@FredOverflow thanks.
@FredOverflow wonder if that uses the method I described above?
 
@RMartinhoFernandes I didn't get the part about the static array either :)
 
9:15 PM
When you create the original shared_ptr it allocates a block for the reference count (and possibly some more bookkeeping) and stores a pointer to that.
 
@RMartinhoFernandes how do you increase a reference count upon being copied.... wait..... you increase the count in the copied and copy.... but then if you copy the copy, that won't work.
 
COPY ALL THE THINGS
 
@Xaade Factory warehouse? You don't need Design Patterns to increase an int, for god's sake.
 
@RMartinhoFernandes so shared pointers share the bookkeeping..... that's the same as a static bookkeeping storage (static array).
 
Then each copy will just copy that pointer, dereference it, and increment it.
 
9:16 PM
@Xaade No. Book-keeping is per owned object.
 
@Xaade Oh, you've never implemented your own reference counted smart pointer? That explains a lot. Sharing the count is usually the first stumble block :)
 
A static array would have static limitations.
 
@RMartinhoFernandes unless you made it 640k huge.
 
@Xeo All of those can be solves with a template<int... Indices> struct indices {}; helper!
 
9:18 PM
@RMartinhoFernandes increment WHAT. A smart-pointers that point to a certain object would need to have shared knowledge to its reference count. If you copy a smart-pointer, you no longer share knowledge to the reference count, unless you make something static or dynamically allocated elsewhere.
 
@Xaade It's dynamically allocated.
3 mins ago, by R. Martinho Fernandes
When you create the original shared_ptr it allocates a block for the reference count (and possibly some more bookkeeping) and stores a pointer to that.
 
@Xaade Smart pointers share an object and a reference count. Ideally in the same memory block. Hello make_shared!
 
The pointer to the ref count is part of the shared_ptr and thus gets copied between them.
 
@FredOverflow ok, and my static array would accomplish that. Array points to an index that contains a count. The only thing you'd have to copy was the index to the array position.
However, I like allocating dynamic memory better.
 
@Xaade Congratulations, you just reinvented pointers for languages without pointers!
 
9:20 PM
posted on January 26, 2012 by Herb Sutter

GoingNative 2012 is sold out for in-person attendees, but online attendance is free and unlimited – live-stream and on-demand. Watch the main page for links. GoingNative 2012 is a 48 hour technical event for those who push the boundaries of general purpose computing by exploiting the true capabilities of the underlying machine: C++ developers. Distinguished [...]

 
So a smart-pointer points to an object and points to an object's reference count..... neat.
 
Shut up Feeds.
 
@Xaade Exactly. Implementing my own shared_ptr for fun was the only time I ever allocated an int dynamically.
 
It's very rude to barge into someone's conversation just to drop a link.
 
int* count = new int(1);
 
9:21 PM
@FredOverflow WOOT!!! 1000 pts.
@RMartinhoFernandes That was a feed? A feed to advertise a money operation.... seems unethical.
 
@Xaade Well, it's sold out anyway...
 
I wouldn't ask for money to make the world a better place....
...I'd gladly fire my co-workers for free....
 
I hope they don't read this chat.
 
sbi
 
But I'm not rude!
Am I?
 
9:26 PM
No.
 
@RMartinhoFernandes Are you root?
 
sbi
@Xaade It's the feed of Herb Sutter's blog. Mostly, it's interesting stuff coming from there.
 
Non-rudeness is easily defined. Dropping links should only happen after a silence of 3 minutes.
 
@StackedCrooked Sounds like a suggestion for meta...
 
6 mins ago, by R. Martinho Fernandes
Shut up Feeds.
 
9:27 PM
@FredOverflow No, I always run as an unpriviledged user.
@Xaade Er.. well...
 
sbi
@RMartinhoFernandes Rather for the newbie hints?
 
Go ahead, I don't have access to that.
 
@RMartinhoFernandes We wouldn't want you getting angry and trying to rmv usr/ java
 
sbi
@StackedCrooked We all fail this regularly. (Hint: You aren't talking of just any links. Otherwise there'd be two violations since the Feed posted.)
@RMartinhoFernandes I'll go ahead and go to bed now. You can bug the @Cat to give you access, discuss the exact phrase you want to add, and add it yourself.
Good night!
 
Good night.
 
9:30 PM
@sbi I think he means unwarranted links. Linking a question/answer for advice, or linking on our current off-topic is ok. Linking on-topic but not on current off-topic topic during active conversation on said off-topic, is clearly annoying and rude.
 
What now what?
 
@CatPlusPlus Ding.
 
"how to stop reading chat and do some coding" =\
 
@Abyx Sounds useful, where can I buy it?
 
9:35 PM
@FredOverflow I don't know =(
 
@sbi I was talking about bot links. But perhaps it could apply to user-links as well.
 
@sbi Hey! I almost clicked that!
 
@sbi it's not an option, what if I'll miss something useful?
 
sbi
@RMartinhoFernandes Well, @Abyx just did.
@Abyx If you're here, you miss coding.
Anyway, as I was saying: I'm missing my bed. <afk>
 
I definitely must star that
4 mins ago, by sbi
@Abyx http://chat.stackoverflow.com/chats/leave/10
 
9:39 PM
Aww, it shows the full link on the starboard. :(
 
:(
 
sbi
@RMartinhoFernandes Star this instead. :)
6
@Abyx ^
 
So, you're still here...
 
sbi
@RMartinhoFernandes Again. I just posted a vile comment against a mod "cleaning out" comments on scifi.
 
@sbi you are so kind
 
sbi
9:46 PM
And did I mention I need to go to bed?
@Abyx :)
 
@sbi Well, you could just take your own advice...
 
sbi
Nah, I could miss something...
 
9:59 PM
stackoverflow.com/questions/9024802/… - guess that means my answer was right....
 
@awoodland This post has been deleted; deleted posts can't be voted on. - I voted to undelete. Can we find two more votes?
 
@sehe I think it's probably too localized though, so undelete just to close/downvote would be wrong
 
@awoodland Undelete to upvote the helpful answer. People may find the question. It is quite well-documented and represents a very common use-case: linkage errors when using headers from an external library.
 
@sehe alright, I'd buy that but I think I'm going to edit to inline the images first
 
10:14 PM
@awoodland: oh dang I was doing the same edit. Did I clobber things? I was gonna crop those images too, do you mind?
 
@sehe go for it, your edit was better than mine
 
Cheers
 
Xeo
@LucDanton Nah
 
@Xeo just built clang off the trunk. Mind telling me what can I expect to find working?
Lambdas?
 
Xeo
no
 
10:17 PM
Damn.
 
Xeo
and no initializer lists
but constant expressions!
Do you use libc++?
 
How do I figure that out?
 
Xeo
Well, did you load it?
 
How'd I do that? I just checked out the sources and ran cmake.
 
Xeo
Well, libc++ has its own repo
 
10:21 PM
Damn.
 
Xeo
Also, did you follow the "Getting started" guide on Clang?
 
@awoodland There. Turd polish completed :) I mean, the images were a bit overkill to begin with, but then again, adding more code snippets to the Q is not going to help
 
Xeo
Aye
 
Yes, except I used cmake.
But that doesn't mention libc++.
 
Xeo
10:23 PM
Well, get the libcxx repo
./buildit
aka follow that guide on the libcxx site
 
@sehe It was fairly complete for a "find my mistake" question which was why I went for a CW answer on it rather than just close in the first place
 
Xeo
and when compiling with clang, add -stdlib=libc++
 
@Xeo Hmm, that describes building on MacOS.
 
Xeo
Yeah, just ignore the "build" part and just execute ./buildit
 
woah his next question has login details for his DB server on the actual Q though!
 
10:29 PM
Wut?
 
@RMartinhoFernandes the next question from the same user as the one we just undeleted and polished: stackoverflow.com/questions/4700953/optimize-sql-query phpmyadmin login details for a real site!
I don't even run phpmyadmin closed from the world behind a firewall I trust it that little
 
I don't even have PHP on my server.
 
Xeo
Btw @RMartinhoFernandes, did you remember to "hack" the InitHeaderSearch.cpp ?
 
No.
It said "If you intend to work on Clang C++ support, (...)", which I don't.
 
Xeo
10:39 PM
No
 
@Xeo: You were wrong about the "signed" part, by the way. Integer overflow always causes undefined behavior. It's just that unsigned integers do not overflow :)
3
Q: How disastrous is integer overflow in C++?

FredOverflowI was just wondering how disastrous integer overflow really is. Take the following example program: #include <iostream> int main() { int a = 46341; int b = a * a; std::cout << "hello world\n"; } Since a * a overflows on 32 bit platforms, and integer overflow triggers u...

 
And FTR, hello world works.
 
Xeo
It should actually be "If you intend to use Clang with libstdc++"
Oh?
 
I guess my libstdc++ is in the default hard-coded path?
 
Xeo
Mine was too
 
10:41 PM
@Xeo see 3.9.1 §4 and footnote 46
 
Xeo
@FredOverflow That was meant as a reply to the robot :)
 
Unsigned integers use modular arithmetic.
 
@Xeo oh :)
@RMartinhoFernandes which by definition does not overflow
So saying that unsigned overflow does not cause UB is nonsense, because there is no such thing as unsigned overflow.
 
Xeo
Details...
 
> really anything can happen and they try to use every piece of liberty to generate machine code which runs more rapidly, even if the result doesn't make sense anymore.
 
10:43 PM
@Xeo I'm mostly interested in details ;)
 
Like, "It's easy to produce a fast program that outputs garbage."
 
It's even easier to produce a fast program that outputs nothing.
 
@RMartinhoFernandes hey, that's what my program does!
 
Xeo
int main();
 
Fail.
@Xeo undefined reference to `main'
 
Xeo
10:45 PM
Yeah, no program output!
 
Can you even declare main like that?
 
@Xeo You don't even have a program.
 
Xeo
Exactly
 
No, that's not a program that outputs nothing.
 
Then why declare main at all? Simply throw an empty file at the compiler.
int main(){}
That's as short as it gets.
 
10:46 PM
#include <stdio.h> // for speed!
int main() { puts("nothing"); }
 
The comment takes too much time to compile, please remove it.
2
 
But the resulting program is just as fast.
 
By the way, what is the complexity of compiling a program? O(n)? :)
 
Xeo
O(scary)
 
That's only if you use SCARY iterators.
 
10:49 PM
hehe
 
@FredOverflow What's n?
 
the size of the program
 
I believe that both lexing and parsing (for LR(1)) can be O(n)
don't know about any later phases
 
O(n) lexing is probably trivial
 
In characters?
Later phases don't care about that.
 
10:50 PM
lexing should be O(n) in characters and parsing O(n) in tokens
 
characters for the lexer, tokens for the parser I guess...
damnit, ninja'd again!
 
Xeo
0
Q: How to deallocate variables on the stack?

FarhadIs there a way to deallocate variables and/or objects created on the stack? I am specifically talking about the stack not the heap. I do not want to debate whether this would be useful or good practise, I just need to know if it's possible. I am using C++.

 
I'm not giving you rep for this.
 
Xeo
I'm at repcap anyways
 
10:51 PM
It's the thought that counts.
 
I just saw a documentary on the Bugatti Veyron. That thing switches gears in 150ms.
 
fuck
 
it takes 4000hp to take it from top speed to total stop.
 
I decided that all of this bullshitting around wasn't worth it and to just go back t dreamhost
 
10:52 PM
but they want me to pay fifty bucks setup fee! :(
 
@DeadMG are they the £9.99/$9.99 ones you mentioned?
 
@DeadMG is that for asp.net hosting?
 
@Xeo That must be the stupidest C++ question in a long time.
 
@TonyTheLion No, PHP but since I've got a static website I don't really care
 
10:53 PM
I pay 74Euros for two years
 
just gonna fix back up what I had with that Amazon hosting
that actually worked
 
right
 
> Sorry, but I am not allowed to share the purpose of it
Lol.
 
can you undo the nameserver changes on mine?
 
Super-secret stack deallocating.
2
 
10:54 PM
sure
I never changed the nameservers on yours
 
@CatPlusPlus lolwut? This is getting better and better.
 
@DeadMG oh ok. never really looked what you did
 
not much
just upload a sample asp.net application so I could see if it was working correctl
 
ah ok
don't worry then
 
> It's impossible. Now you know, and you can get on with your life.
 
10:55 PM
lol
@CatPlusPlus link?
 
"Blasted, my evil plan to conquer the Earth via carefully placed premature stack deallocations is foiled."
 
@TonyTheLion What @Xeo linked above.
 
Gosh, linking this project is so loud.
 
man
I bought some chocolate ice-cream instead of caramel ice-cream
made me sick :(
 
Nothing new?
 
10:58 PM
but rather irritating
it's not that caramel isn't tasty, just that I like variety
 

« first day (467 days earlier)      last day (4472 days later) »