« first day (693 days earlier)      last day (4481 days later) » 

00:00
@sehe Yes, it tells me that a lot of conditional jumps depend on uninitialised values. I thought it could be a symptom of the problem, as well.
@StackedCrooked I don't think you can have any issue with static_cast unless it involves void*. But I may be lacking imagination.
I had one where I wrote past the end of the array and caused each of my functions to grab an extra 33k of stack space.
@MooingDuck Which is better: Yours: ideone.com/7wJ5G or noskipws: ideone.com/WeH90
@MohamedAhmedNabil probably noskipws
@bitmask LOL. You think?
00:01
@MooingDuck does yours add any extra feature or is it the same?
@sehe Well, I'm not entirely sure, because it happens during the recursive descend.
@MohamedAhmedNabil you're displaying "The value stored in string str was" even if it reaches the end of the user's input.
@MohamedAhmedNabil other than that they're the same I think
@bitmask Where's your program?
There are about 17 recursive steps. That shouldn't manage to overflow the stack
@sehe What do you mean?
@bitmask Depends on what else you do on the stack
@bitmask Can I see it?
00:03
gdb tells me there are 43 calls on the stack, in total.
@MooingDuck huh?
@MohamedAhmedNabil the while(getline( causes it to keep going until you break or until it reaches the end of the input
@sehe In theory, yes, but I don't even know how to begin extracting the relevant parts. It's not exactly small.
look at the bottom of ideone:
input: no
output:
Enter a number:
The value stored in string str was: 0
@bitmask The size of the stack frames matters, as well as total stack size. Anyways, it's probably not a stack overflow then. I'd just start with the first reported unitialized value reported by valgrind and fix all the related code :)
00:04
I've been using some C++11 features I'm not yet 100% familiar with, maybe I messed something up, with that.
Is it just me, does chat seem to be running very slowly?
What part is slow?
@MooingDuck both programs use while(getline
Scrolling... probably my computer.... hard drive light is going crazy...
@sehe I obviously tried that, but I cannot see any problem there, everything looks perfectly initialised. Maybe I have to do some more investigating ...
00:06
@Chimera Soooo your browser's scrolling is diskbound? Swap thrashing?
@MohamedAhmedNabil yes, but look at the end of mine, after the loop. if(cin)
@bitmask How can it "look" initialized when it is reported to be unitialized?
@bitmask initialize yer variables
@sehe Don't know... I'm running inside a virtual machine... could be some crazy stuff going on.
@bitmask You can just trace the path to the point where it fails. You know valgrind --db-attach=yes, right?
00:07
@sehe All variables are properly constructed?
sudo -E valgrind --db-attach=yes ./test # get around permission issues the easy way
@bitmask Obviously not. Duh. Rule #1: To fix a problem you must acknowledge you have one.
@MooingDuck I was meaning to ask you about that. So its really if(cin) that is causing the change?
@MohamedAhmedNabil yeah, it checks to see if all reads from cin succeeded. If they did, we know there is a number. Otherwise, it failed
@MooingDuck So basically if one cin>> fails . cin will always return false?
@sehe Well the jump happens in ceilf (s_ceilf.c) which is called by hashtable_policy.c, so deep inside library code. The first outer function looks fine.
00:11
@MohamedAhmedNabil until you call cin.clear() yes
@MooingDuck Nice! Did you come up with that on the fly?
@bitmask irrelevant. Without full code, there's not much I can say about that. Other than that 'deep inside library code' doesn't mean it isn't your error. The problem may manifest it in library code, though you cause it
@MooingDuck aww...
that's the first point where valgrind starts complaining. in line 47, that is
00:12
@Mysticial that was a great comment
@MohamedAhmedNabil also good to know: it will ignore all >> after the first fails until you .clear() it
@bitmask check the validity of iterator parameter it, and whether unfold leaves the tree immutable. Iterators will be invalidated if the underlying collection changes. See the docs for precise specification when this may occur
I think I can see that func must be declared to take the content as const&, so that looks relatively safe
@MooingDuck so its a good habit to always clear()
@MohamedAhmedNabil after a failure. The important habit is to check for failures.
@bitmask good luck with the debugging. Pro tip: when valgrind says a value is uninitialized, listen to it!
I'm off to bed, cheers
00:20
night
@sehe thanks so far!
00:38
here

int i;
cin>>i;

if the user enters a letter, why does i=0?
@MooingDuck ?
The numeric value to be stored can be one of:
— zero, if the conversion function fails to convert the entire field. ios_base::failbit is assigned to err.
— the most positive representable value, if the field represents a value too large positive to be represented in val. ios_base::failbit is assigned to err.
— the most negative representable value or zero for an unsigned integer type, if the field represents a value too large negative to be represented in val. ios_base::failbit is assigned to err.
First case.
@LucDanton Any other cases?
I'm not super familiar with this part of the Standard Library, but I believe that's it.
@MohamedAhmedNabil because i just coincidentally happened to have the value 0 before the >>.
@LucDanton oh really? I thought it left the variable alone
@MooingDuck yea
00:48
@MohamedAhmedNabil Luc says I'm wrong, and he has a source to back him up
@MooingDuck i was actually 0, when i changed the value of i to 6, it changed to 6
@MooingDuck Had no idea myself. I wonder if you can imbue a stream with a numeric locale that doesn't do that and pass that stream to code that does expect formatted extraction to fill with 0 in case of failure, just to see something crash and burn.
int i=6;

cout << "Enter a number: ";
cin>>i;
cout<<i;
This outputs 6
00:51
I get 0 if input is ill-formed.
@LucDanton meaning of ill-formed?
@LucDanton too advanced man
@MooingDuck got something too add?
00:54
Avoiding std::cin makes it explicit what we're trying to extract from.
@LucDanton let me check wat <cassert> does
it's.. in the word
o.o
Could use static_assert too
@MohamedAhmedNabil it should be zero, if it's not zero, it's a bug in that cin object.
@Rapptz he doesn't know what assert is
@MooingDuck wait a sec
@MooingDuck It's an english word.
01:00
int i=6;
cin>>i;
cout<<i;
@MooingDuck shouldnt this output 6?
not unless cin is in error state, or the user types 6
why did you think it should output 6?
Youtube got a new look.
@MohamedAhmedNabil no, should be zero
@Rapptz not everyone knows all English words.
@Cheersandhth.-Alf im assuming the user entered a letter
@MooingDuck test it
@Cheersandhth.-Alf I accidentally told him it did a few minutes ago, then Luc corrected me
01:04
@MohamedAhmedNabil I've already provided you with a demo.
@LucDanton prints six on ideone: ideone.com/ZlNO4
@MooingDuck Actually, most likely nobody (or very few people) know all English words.
Uhm ... do I have to std::move an rvalue reference that comes out of a function call (as return value)?
01:06
@LucDanton I believe LWS does it right. But that doesn't change the fact ideone (and probably whatever Mohamed is using) is wrong.
@bitmask Depends on the return type and what you want to do exactly.
@bitmask no
auto x = foo();
@LucDanton not if it's already an rvalue reference
@MooingDuck You try with a move-only type then.
01:07
foo returns an rvalue ref and my stack is screwed with that line and is fine without it.
What does the reference refer to?
Local variable in 5, 4, 3...
@LucDanton Very funny :)
what does assert do?
the return statement looks like this
return std::move(local_variable);
@MohamedAhmedNabil crashes the program if the condition is false
01:09
So you are referring to a local variable then?
@MooingDuck simple enough
@MohamedAhmedNabil It asserts an expression to be true.
@bitmask that's not allowed
@MooingDuck I thought that was the point of returning an rvalue reference.
@MooingDuck It is. But it leads to bad things.
01:10
I'm extending the lifetime of a local variable
Here, attempting a copy from a stale reference.
@bitmask No such thing.
@bitmask no, that doesn't work
int&& foo() { int i; return std::move(i); } is the exact same kind of evil as int& foo() { int i; return i; }. They really do mirror each other.
@LucDanton Assertion fails at i==0, should that happen?
@LucDanton I see. Then, this was my mistake, I was convinced move would specifically allow me to do this.
01:12
@MohamedAhmedNabil your standard library is non-conforming (it's breaking the rules)
Can I avoid copy construction by using rvalue references as return type?
@bitmask you cannot extend the lifetime of a local. Period.
@bitmask either copy or use dynamic scope
@MooingDuck how do i fix that
@MohamedAhmedNabil what compiler are you using?
@MooingDuck But I can extend the lifetime of a temporary (aka rvalue).
01:14
@MooingDuck UB.
@MooingDuck MS VC++ 2010
@LucDanton say what?
@MohamedAhmedNabil The only way to get a compiler that conforms in that way is then to get a new IDE. (I don't recommend that, cin>>i is too unimportant)
@MooingDuck Well, I don't think that was your point. Regardless of that, I don't see how that goes against what I said. I'm really confused as to what you were trying to said back there :(
@MooingDuck I should just ignore that minor detail?
@LucDanton you don't have to move an rvalue from a function into a local variable
@MohamedAhmedNabil yes. It's so minor I've been doing this for 8 years and never knew about it
01:16
@MooingDuck ... but there's a call to std::move right there.
@LucDanton not from the variable the function is returning. The move is in the function.
And it's unnecessary to boot. WTF.
@LucDanton yes it is, that's aside from the point
11 mins ago, by bitmask
Uhm ... do I have to std::move an rvalue reference that comes out of a function call (as return value)?
And it goes without saying that you don't have to move rvalues. std::move is for lvalues.
@MooingDuck I took that to be about the return statement.
Isn't it?
@LucDanton I took it to be about moving "an rvalue reference that came out of a function call" into a local
user406009
01:19
What do you guys usually do when you want a unique identifier?
@EthanSteinberg afjklsbfdjklbasf
user406009
I am thinking of incrementing a uint64_t. Will that work?
@EthanSteinberg that too
anyway, time for me to go home. later all
@MooingDuck Given how the rest of the conversion went (esp. the code snippets), I don't think that's the right interpretation.
user406009
Oh well, uint64_t it is. Hopefully nobody ever goes past 2^64 transactions...
01:24
@EthanSteinberg Yes, it's like ... who will EVER need 2^32 IP addresses. That'd be madness ... wait a second.
2^32 != 2^64
Obviously. But it's the same line of thought.
18 quintillion is quite a bit
@Rapptz So are 4 billion, if you're trying to connect a handful of universities.
0
Q: ifstream best way to read without memory usage

soniccoolI have a textfile that contains authors and the books written by authors. I am assigned to write a program in that the user will provide the name of a author. And the program must print the name of any books written by that author. I understand that i am supposed to use an ifstream to read this ...

02:24
how do i aceesss bookmarked chats?
@MohamedAhmedNabil Should be in your chat profile.
03:03
hallou
03:19
5 pints later, damn it, why am I still hanging on here?
@EtiennedeMartel Because it sometimes make compile times pass quicker?
@bitmask I'm not in any position to make anything compile.
I think I should get some sleep.
03:38
Is Loki a good library?
@StackedCrooked Define good. It was quite ground-breaking when new, but for actual use, Boost covers most of what it had, and is more portable, more actively supported and developed, etc. In short, educational, but I can't think of much from it I'd plan on using directly in real code today.
It has a few unique ideas concerning multi-threading.
Ah well.
@StackedCrooked As I recall, it predates Andrei understanding threading very well though, so (for one thing) it depends on using volatile for synchronization, so (unless it's been rewritten) some of it only sort of works by accident.
03:55
IIRC Andrei declared (user-defined) objects as volatile and used volatile methods to mark methods as thread-unsafe. The volatile methods could only be called after a lock was in place.
Or something like that :)
04:43
Evenin'!
If anyone has experience with SCons, I'm trying to figure out what to put in the SConstruct file to compile with g++-4.7 rather than g++
env = Environment(CXX = 'g++-4.7') is a possibility.
And then you use that environment for your targets etc. or to clone additional environments.
Awesome! Thanks for your answer, Luc
How're you doing?
guys, when you are trying to stream a video or file from your source to destination, do you convert the file into a huge byte array first and then send to the destination and the destination receives it byte by byte?
Why does everyone use mod 1000000007
@LucDanton, worked like a charm. Thanks!
04:54
It's those online competitions.
I was like man this is weird.
If they're asking how to do mod 1000000007, it means they won't win.
@Mysticial What's so hard about doing mod 1000000007
everybody keeps trying to power everything up before they do the mod...
I answered like one of those questions... but then they kept on coming...
now I just kinda ignore them
13
A: Need help in mod 1000000007 questions

MysticialThe key to these large-number modulus tasks is not to compute the full result before performing the modulus. You should reduce the modulus in the intermediate steps to keep the number small: 500! / 20! = 21 * 22 * 23 * ... * 500 21 * 22 * 23 * 24 * 25 * 26 * 27 = 4475671200 4475671200 mod 1000...

I like SO's search, it's easy to find things
04:59
yeah, I only got like 5 upvotes on it after the first day.
The rest of them came from all those contestents googling for it.
Who'd ever thought that to be one of my most googleable answers.
My other googleable answer is an AVX question.
I just made my own big integer class
long ago.. for project euler.
I didn't use it as much as I thought though =/
They should start putting obscure performance problems on project euler... :)
They're almost all algorithm problems.
The math isn't complex or anything
It'd kinda sad actually. I really can't answer anything on SO that isn't either a newbie question, or a C performance question...
Occasionally I'll do a math/algorithm one... but that's rare.
I try to avoid all the template/OOP questions..
I'm not very good at it
05:03
I don't think I've ever been able to answer a single template question.
The OOP questions are just weird.
Why are they inheriting so many classes...
How come double/float max/min are so large?
cause they're floats?
10^308 for double I think
yeah
look up floating-point representation
I think the exponent for double-precision goes up to 1023
2^1023 * whatever the max mantissa is
@Mysticial A double normally has a 53 bit mantissa, so around 2^53.
05:11
Oh I see.
user406009
They should add a BigInteger class to the standard library.
It's easy to implement on your own.
user406009
Yeah, but not easy to implement well.
user406009
And a BigInteger would be perfect for standardization. It's just math, no OS dependent fiddling needed for implementations.
@EthanSteinberg That actually argues against standardization, at least to some degree. Since it can be written perfectly well after the fact, its being in the standard doesn't really gain a whole lot.
05:20
I'd like it to be standardized but it's trivial.
@JerryCoffin I think that's the old approach of favouring standardising existing practice, isn't it?
It's been rejected multiple times. They won't want a crap implementation, and an efficient one is far too difficult to write.
user406009
@JerryCoffin Then why did they go through all the trouble of adding std::unordered_map to the library? That can also be done perfectly well with a user-written library.
@Mysticial Most things don't have a reference implementation in C++ though.
@EthanSteinberg Existing practice. Everybody already had hash_maps when they had maps.
I should say, the problem is that achieving even a small fraction of the speed of say GMP is already beyond difficult.
So they just won't bother with it.
So instead of pushing crap, they're just gonna leave it out.
Then you also have the issue of what run-time complexities they want to achieve.
05:23
0
Q: Where could you download the static library/header for the standard math library for c?

scrat101I have googled and looked all over, but can't find it ANYWHERE. Anyone know where to get it?

If they want full O(n log(n)), you're talking thousands and thousands of lines of (hardware-dependent) code just for a single library.
I don't think any single one of the STL classes are even close to that.
I thought a lot of the STL classes were O(n log(n))
@Rapptz O(n log(n)) is not easy to achieve for BigInteger.
Not to mention that the fastest O(n log(n)) algorithm for multiplications isn't even provably correct unless you use extremely conservative (and slow) parameters.
Hurray, I unununbroke my code.
Was it something really stupid?
05:33
Well, no. I full-assed a half-assed redesign that didn't manage to replicate all the features of an undesigned addition of features.
Maybe I should update my BigInteger library.
All it does is multiply and add lol
divisions are a bitch
How do I make my bitbucket readme look pretty
Kinda like the robot's github. rmartinho.github.com
That's github though.
True. I could use github since it's a public repo anyway.
05:40
I'm not saying that bitbucket doesn't support that, because I really have no idea -- but I've always been under the impression that github is exuberant with features while bitbucket is a bit more conservative. I could be wrong though.
That being said the documentation is very helpful IME. I'd look there.
For bitbucket or github?
Isn't this about bitbucket?
Yeah, but we were mentioning both so it was ambiguous kinda.
I answered my first newbie question in like 2 months...
And it's an actual C++ question too... I'm proud.
How did I miss that question lol
Congratulations by the way.
Have an upvote, etc.
05:46
It's probably the first "real" C++ question I've answered in like months...
@Rapptz lol, thx
The other answer is better though.
user406009
The other answer assumes C++11.
C++11 is in the tags.
and title.
I just answered the question that was asked.
It's still right.
05:51
I'm searching my recent answers. I'm on page 3 and I still haven't found a "real" C++ question...
Ah... finally found one... March 1st... was my last "real" C++ answer. And it's also a newbie question... haha
Try this one. It's easy and almost a duplicate
0
Q: Deleting duplicates in an array (C++)

codingloccI saw an older post on here asking how to do relatively the same thing, but their approach was different and i'm interested to know the hole in my program. I am attempting to write a program that accepts characters into a 10 character length array. I want the program to evaluate the first array ...

All my other answers since then are a mixture of C, assembly, OpenMP, and SSE. With a couple of performance ones here and there.
Should I take care that auto expr = ref(0); is safe, or put the burden on the user?
@Rapptz tl; dr
@LucDanton in what scenario would it not be safe?
lol
05:56
It's a trade-off in usability. Either auto expr = ref(0); involves a stale reference, or auto expr = ref(std::move(i)); involves a move construction.
@Rapptz yep... that's why long and detailed posts rarely get a lot of votes... tl;dr
His code is pretty bad anyway. Once you ignore that and look at the title you can answer it.
During my repwhoring days, I posted a lot of answers without actually reading the question.
I'm not super fond of introducing another name to separate the functionality either. The distinctions between ref/val/var (and not using one of those altogether) are already somewhat subtle.
And to also speed-debug. Scan of the code, and post the first error you find.
05:57
I can't rep whore. I don't know how. I'm also "scared" or being downvoted a lot.
1. Be fast.
2. Post a short answer first.
3. Edit it into shape.
4. Don't hesitate.
5. Don't be afraid to delete once you start getting downvotes.
Though it does take 5 downvotes to equal one upvote.
I almost always deleted as soon as it goes -1. There's one instance where it got to -2 before I could refresh.
I've never let one get down to -3 though.
I saw I had an answer at -3. The answer wasn't even wrong since the question was subjective but I deleted it and got a badge and rep back
I've deleted multiple +3s before.
Dupe or wrong answer...
Both were back when I used to repcap every single day. So it didn't matter.
06:02
I think I'm going to remake my BigInteger with C++11 stuff.
Whenever I get the time (which will probably be never), I wanna build a C++ wrapper around the bignum classes in my pi program.
I can still help you learn allocators!
lol, yeah
How did you implement it? The way I did it was pretty shitty.
It was an array that basically had carry
@Rapptz It's a C interface right now.
A very low-level close-to-metal C interface.
operator-overloading is gonna tricky to do if I want to let the user specify parameters like:
1. Precision
2. # of threads
06:23
0
Q: integer overflow in matrix exponentiation

k53scI have been trying to produce several sequences with require matrix exponentiation. My code produces correct values for small cases.I have provided below 2 different matrix which I have been using for 2 different sequences. Matrix1 [2 1 -2 -1] [1 0 0 0] [0 1 0 0] [0 0 1 0] Martri...

This guy is asking solution for a ongoing online programming competition. Is it okay?
Yeah, it's fine.
We were talking about it earlier
It's not like homework questions which you aren't supposed to completely answer.
I had faced the similar problem, now I am wondering if I should answer it.
Why would this belong in Meta.SE?
06:25
math.se?
@nneonneo: If so, then it's off-topic for stackoverflow and belongs on meta.SE, probably. — David Schwartz 1 hour ago
oh probably
Wow he's using macros
macros are awesome
He has copied the code.
Uh, I know the complete story about this question.
Macros are mostly used for coding quickly during competetion
I edited his ugly formatting
I was thinking of mass editing ugly code snippets but that's like too time consuming to wait for 2 people everytime.
07:02
Write a bot to do it for you.
07:17
In vim, is it possible to copy lines (in visual mode), and then paste them as flipped?
In Vim, is it possible to …? Yes.
I found some link to do that, but it is rather messy and hard.
07:43
Benign paroxysmal positional vertigo (BPPV) is a disorder arising in the inner ear. Its symptoms are repeated episodes of positional vertigo, that is, of a spinning sensation caused by changes in the position of the head. BPPV is the most common cause of the symptoms of vertigo. Classification Vertigo, a distinct process sometimes confused with dizziness, accounts for about 6 million clinic visits in the U.S. every year, and 17–42% of these patients eventually are diagnosed with BPPV. Other causes of vertigo include: * Motion sickness/Motion Intolerance: a disjunction between visual stim...
^ Sucks. Got diagnosed yesterday. It just came upon me out of the blue. Now I feel nauseous every time I turn in my bed.
Maybe it will just pass :)
@StackedCrooked Try looking down from the top of the Eiffel Tower.
Bastard :P
Just thinking about makes me puke.
Sorry :P
08:09
When I see commands like :nno \d2 :g/^/kl\|if search('^'.escape(getline('.'),'\.*[]^$/').'$','bW')\|'ld<CR> I feel vim is a language.
and a difficult one.
08:58
I’m going to put a Python interpreter in the daklang standard library.
Goedemorgen, fellow Dutchman.
Good moaning
evening
09:15
I have been thinking of a syntax like this.
import io;

def n `!` {
    return n * (n - 1)!;
}

def main {
    n = io.readLn<Long>();
    io.printLn(n!);
}
However, I am having trouble with the precedence of custom operators.
lol.
Python with braces
@Rapptz from __future__ import braces
>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance
{ your.self; }

^ brace yourself :)
{ you.self }
:P
One way I could do precedence of custom operators is with indices, but that’s as unmaintainable as line numbers in BASIC.
09:20
@StackedCrooked too late :(
@daknøk HasPrecedence<Op1, Op2>::value;
heh.
def n `!` precede `*` {
    if (n < 2) return 1;
    return n * (n - 1)!;
}
Must be doable.
09:46
Why is everybody inventing their own language these days? :)
Because boredom.
There is so much other stuff you could do!
Like, learn other existing languages.
Such as?
Or do sports. Or partying with friends.
Anything not solving hypothetical problems you’ll never encouter and writing video games will do. :p
09:48
Actual math problems are so much more interesting.
I don’t want to solve a problem for the sake of solving a problem.
You never had a math orgasm?
no ಠ_ಠ

« first day (693 days earlier)      last day (4481 days later) »