« first day (1620 days earlier)      last day (3311 days later) » 

12:00 AM
It was actually trying to get the representation of 123.4567 using the current API :)
Which the only way I could think of was 1234567 / 10000
Which made L = 3, T = { 0, 456700000, 123 } and exp = -2
thought it was chuckle worthy
 
lol
 
work on yo post-conditions
 
yeah, you need to always strip out leading zeros before returning. Otherwise, it will fuck up division and square root.
@Rapptz It's in a comment. Just not enforced via an assertion. :)
 
123+0.4567
 
i wanna write a HTMLWriter class. is there a design pattern that relates to how i should add each "rule" (html tags)? i'm thinking of making them their own classes and somehow building them up (like all table data) and making the HTMLWriter class read the data and convert to html.
 
12:05 AM
Types Don't Know # approach?
Or the Sean Parent way of doing it.
 
@Rapptz is that for me?
 
Yes.
 
welp, 1 hour vid. cya late night when i'm still doing hw because i can't not procrastinate
 
@Blob You can always procrastinate.
 
12:19 AM
How is the Hamming distance an upper bound for the Levenshtein distance ??
They both require single-character edits..
"If the strings are the same size, the Hamming distance is an upper bound on the Levenshtein distance."
I was able to fix it. Here is the cleaner code:
(the for loop ends after line 36, but the the last bracket is not shown)
 
@JerryCoffin I see you posted an answer here. I fixed your bug.
Surprisingly you code was basically exactly my "naive" approach posted 5 hours before your answer. But your code is somehow faster than it. Anyhoops, the perfect hash is equally fast.
 
@DonLarynx ^Screenshots :-/ ...
 
@DonLarynx who is that target audience of your comments?
 
@sehe Yeah--though I'm not sure there was really a bug (if memory serves, << should be higher precedence than |, so the parens shouldn't make any real difference). I probably wouldn't have posted it at all, but I didn't notice that you had essentially the same code as your first attempt.
 
@JerryCoffin There was clearly a bug since the result was off :)
 
12:34 AM
@sehe: On strings of equal size, why is the Hamming distance an upper bound on Levenshtein if they both require single-character operations?
 
@sehe At least for me, it seems to produce identical results with or without the parens.
 
@DonLarynx yawn
@JerryCoffin mmm. I don't think I missed that I changed to lowercase letters after that? Mmm. That would be an embarassing thinko
 
-3
Q: How to find all the classes called in an execution of C++ code?

AlessandroI need do a dynamic analysis of a c++ code. I want to know which classes are used during an execution at runtime. How can I do it? Is there any dynamic analyzer that can do it? I checked valgrind, but it doesn't work on Yosemite. Thanks

Thoughts?
 
nm + grep + visibility options
 
@πάνταῥεῖ Tool recommendations are off-topic.
 
12:38 AM
@sehe Hamming substitutes, and Levenshtein substitutes, inserts, and deletes. But you don't delete or insert on equal string lengths. So you're left with Hamming and Levenshtein, both which only perform operation substitute.
 
@Blob That’s not the kind of question that the prohibition targets. Think 'What is the best compiler on system X?'.
 
@JerryCoffin You're right. Somehow my brain shortcuted earlier. Of course the checksum didn't match because you had uppercase digits. I've just reconfirmed that the parens don't matter
 
@sehe I can beat your perfect hash
 
@DonLarynx hello? are you talking to me?
 
@LucDanton wouldn't that fall under the opinionated one?
 
12:39 AM
@Blob True. But something like gcov is pretty standard. I'm just interested if this actually could be achieved with it.
 
@orlp beat or match?
 
@sehe Slightly beat
but mine can be vectorized into oblivion
 
@orlp Prove it :)
 
no branches, pure adds shifts and mults
 
@orlp Makes sense. Jerry's also is on par / maybe a percent above
 
12:42 AM
@sehe meh too lazy
 
@DonLarynx what if he has thousands of classes?
 
@orlp Looks like it loses slightly: paste.ubuntu.com/10665211 (mine's on top, jerry's next, bottom two runs are yours)
 
@sehe That's a bit of a relief. I thought I'd tested it enough to catch anything that trivial.
 
@sehe Yes.
 
@sehe what flags?
 
12:44 AM
@JerryCoffin I guess I assumed it would make sense for me to find a bug since you deleted it for some reason :( Assumptions o.O Sorry about that
 
@sehe if you are on 64 bit, use -m64, and always use -O2, -O3 is broken
 
Right.
What use is -m64? It's already 64 bit anyways
 
To make sure you compile for 64 bit
@sehe not on mingw
 
Also, as you can see the comparision is fair
 
@sehe Oh, no problem. I just deleted it because after more looking, it seemed to be a dupe.
 
12:46 AM
depending on distributino
 
@orlp so f. what :)
 
@Blob It’s not exclusive.
@sehe Cross compiling from 32-bit.
 
I never do
I know my system. I work on it everyday and I tend to keep it pretty straightforward
@orlp paste.ubuntu.com/10665249 no diff (actually noticeably worse)
 
@orlp -O3 is not broken.
Please stop spreading this myth.
 
holy text wall batman
1
A: Can Aliasing Problems be Avoided with const Variables

jschultz410 Is an aliasing problem possible here, or does the fact that foo is only initialized, and never modified save me? First, there can be no aliasing problem because your code only performs reads on the aliased memory, which is safe. Second, even if your code did do reads and writes on the alias...

seriously the longest answer I've seen
also probably has issues
 
12:51 AM
51
Q: Is optimisation level -O3 dangerous in g++?

DunnieI have heard from various sources (though mostly from a colleague of mine), that compiling with an optimisation level of -O3 in g++ is somehow 'dangerous', and should be avoided in general unless proven to be necessary. Is this true, and if so, why? Should I just be sticking to -O2?

 
The discrete distance between vector space elements also qualifies as a Hamming distance.
 
@orlp The x64 MinGW-w64 targets are 64-bit by default.
 
When I said -O3 is broken I didn't mean it generates buggy code
I mean that performance usually ends up being better with -O2
 
That's not true either.
 
It is when you code becomes more than trivial examples and instruction cache matters
O3 just generates too large code
usually
 
12:55 AM
@orlp O3 is the experimental or being worked on bits of the optimizer. AFAIK it will still produce correct code. But might not always be faster.
 
that's bull though
 
It is.
The only thing that causes larger code in -O3 is -funroll-loops
 
might've been true at one point, I'm no historian
 
iirc
 
It has fun in it. It’s clearly harmless.
 
12:56 AM
@orlp except it's not, the vectorizor is still very speculative and still a work in progress
 
Source m8
Cause this sounds like straight up bullshit
 
also without profiling it's near impossible to get heuristics on when to unroll loops
 
I looked it up and -O3 doesn't do -funroll-loops.
 
@sehe "1234567890" and "0123456789". Levenshtein takes two operations and Hamming takes 10.
 
There's -funswitch-loops though.
 
12:58 AM
@DonLarynx I bet.
 
a truly cryptic attempt this time :P
 
@DonLarynx Why are you doing this again?
 
> Since GCC 5, the option -fextended-identifiers is enabled by default for C++, and for C99 and later C versions.
cc @LucDanton
 
12:59 AM
@sehe Interest. I don't want to go to an interview and get asked "Why is the Hamming distance an upper bound for Levenshtein?"
 
lol. Maybe get some rest
 
There was this answer on cstheory.se and it said at the end "Therefore the Levenshtein distance between a and b is no more than k. But it could be smaller than k, of course."
 
@Rapptz looks like I was thinking of -Ofast
 
it didnt really tell me anything
 
@orlp Yay Reached parity now
 
1:01 AM
@DonLarynx To be fair, if you know what Hamming distance and Levenshtein are then you should be able to answer that on the spot.
@sehe what do you mean?
 
@orlp I meant it runs as fast. But I just noticed the checksum doesn't match. Investigating
 
@Rapptz Yay! Hopefully the lexer does its job, too.
 
mine's probably bugged
most likely differing endianness
 
@sehe I don't have an interview anytime soon.
@orlp I didn't understand why Hamming is an upper bound for Levenshtein. Now I do.
 
is there any practical application to this...?
 
1:04 AM
Of course
 
i can't imagine it.
 
@Rapptz That’s not even in my days-old snapshot lol, where did that come from?
 
permalink is borken lol
 
@orlp something is wrong. Entry rejected :)
 
1:05 AM
shit wiki
//file UCN_almost_UTF8_identifiers.cpp
lol
 
Oh my god
Minecraft and kids are both cool and tiring somehow
 
@Rapptz Ah, so the non-lexing is documented. Oh well.
 
I'm on break AMA
 
> error: universal character \u0317 is not valid at the start of an identifier
Really? What’s wrong with π?
It does work when not at the start. Neat! Useless, but neat!
 
Skilled ppl measure twice, cut once - I am semi skilled. I measure twice, cut twice.
 
1:07 AM
wait I'm dumb
why doesn't this print anything? coliru.stacked-crooked.com/a/877454db67b0a09c
I'm derping right now
 
Well unless you use a workaround in your build steps like they suggest I suppose.
Ya know what we mentioned formulas not too long ago, and I’m fairly sure I’ll use Unicode in identifiers when the support is here.
 
@orlp idk that seems fool proof
 
@orlp what's your input?
 
@chmod711telkitty look at the command line below
 
I'd use unicode in identifiers for math only.
 
1:10 AM
There should be negative reputation on SO
.
 
@sehe do you understand this? coliru.stacked-crooked.com/a/877454db67b0a09c
I'm pretty stumped right now
 
@orlp You read less than count (sizeof(buffer)) so failbit | eofbit is set.
 
@DonLarynx There really is, but to be more welcoming to newcomers, they keep it hidden. In reality, what would show as 250,000 rep is really 0. Anything less than that is really negative rep.
 
@orlp Look at my code. It's iostream 101 :)
 
@Rapptz I tend to have stuff like float_type alpha = …; , it kinda invites itself no?
 
1:12 AM
@Rapptz Not sure about failbit (actually, I don't think that's required). Instead, check gcount()
 
oh I don't ever use unformatted istream, I always use C style IO
 
> end of file condition occurs on the input sequence (in which case, setstate(failbit|eofbit) is called. The number of successfully extracted characters can be queried using gcount().
 
@chmod711telkitty What's your measures missy? (That's sexist yes ;-)!)
 
I’ll start with stuff where the formula is referenced in the comments. Foolproof!
 
So why did @orlp code not compile?
 
1:13 AM
@πάνταῥεῖ Go home
 
It did compile
 
It compiled.
 
it just didn't run as I expected
 
He's just a noob.
 
1:14 AM
:/
 
I falsely assume that cin.read worked as std::fread
 
:3
 
@sehe I am already!
 
> g++-trunk -std=c++1z -Wall <(perl -pe 'blah blah' <main.cpp)
 
polymorphism == overriding ? (praise_me) : (neg_me_into_oblivion)
 
1:14 AM
something wrong with that stuff? The final fd is empty, or so the error tells me.
 
@DonLarynx neg neg neg neg
 
Ahhh
 
> what would show as 250,000 rep is really 0.
wat
 
@JerryCoffin that doesn't really tell anyone how much data was read... :/ I don't assume you want to ignore the last n kilobytes just because it was a short read?
 
welp, pipeline it is
 
1:16 AM
@sehe yep the issue was endianness
 
@DonLarynx what is this, lisp?
 
I assumed little endian, but it's big endian of course
 
@sehe Why would the last n kilobytes be ignored? On the last (fragmentary) read, the loop will still execute. It's then up to them to use gcount() (again) to know how much of the buffer to process. It'll break out of the loop when the read fails completely (i.e., nothing more is read).
 
Ah. Yeah. I was missing the use of gcount() there. I mean, it's rather redundant like it is, no?
 
@sehe Your template ignores the last block
because cin.read will return false if it doesn't read a full block
 
1:18 AM
@orlp Prove it (sigh)
@orlp Really. How did it work for me then
 
@sehe you passed in multiples of 4096?
or all code ignored the same length trailing from the end
Try and verify and see if your output length is exactly input / 4
 
@sehe No. At least I don't think so.
 
Could be. That's a stupid bug then. And why does it indeed fail. That's a stupendous interface blunder IMO
@JerryCoffin I just found out indeed
 
How do you guys prefer to test private methods in a class? I read #define private public was evil and I shouldn't be using it
 
I (mostly) stick to testing the public interface.
 
1:21 AM
@sehe One of my earliest encounters with iostreams was replacing some code that did something like while (fread(s, 1, n, buffer)>0). By the time I got the iostream code to work, I was quite disappointed.
 
I've just fixed 6 sample programs :/ Now for the links (coliru + godbolt)...
@JerryCoffin I thought I had this trick down :/ I'm getting to the disappointed stage too now
 
> In Java, all non-static methods are by default "virtual functions."
 
There's a reason I like to use C style I/O
 
@orlp because it has all the same issues as c++ io but in a procedural wrapper?
 
I think I'm going to end up learning JS soon.
 
1:29 AM
Any clue why (U+2208) would be rejected in identifiers? (I think both Clang and GCC reject it.)
I thought it was 'anything goes', there’s just Annex E.2 which lists a handful of forbidden ranges (at the start of an identifier) which AFAICT are combining marks.
 
Private functions only have class scope. T or F?
 
@sehe and with a lookup table instead of using ASCII code ranges: coliru.stacked-crooked.com/a/337edeb9648fcb4c
 
Yup looks correct. Not the fastest still though: paste.ubuntu.com/10665446
@orlp Hang on
 
9
A: 😃 (and other unicode characters) in identifiers not allowed by g++

kennytmAs of 4.8, gcc does not support characters outside of the BMP used as identifiers. It seems to be an unnecessary restriction. Also, gcc only supports a very restricted set of character described in ucnid.tab, based on C99 and C++98 (it is not updated to C11 andC++11 yet, it seems). As described...

 
@orlp ahahaha. Looks like we have a winner
sehe@desktop:~/Projects/bin2hex$ pv /tmp/huge.bin | ./orlp3 |md5sum
3.81GB 0:00:02 [1.35GB/s] [==================================>] 100%
940b29c57b873d95f2d07ed4e391eccd  -
You should post that. It wasn't a fluke. I ran it a few times
 
1:35 AM
@sehe could you do one last profile?
 
@LucDanton There are a few other exclusions:
> If the hexadecimal value for a universal-character-name corresponds to a surrogate code point (in the range 0xD800–0xDFFF, inclusive), the program is ill-formed. Additionally, if the hexadecimal value for a universal-character-name outside the
c-char-sequence, s-char-sequence, or r-char-sequence of a character or string literal corresponds to a control character (in either of the ranges 0x00–0x1F or 0x7F–0x9F, both inclusive) or to a character in the basic source character set, the program is ill-formed.
 
@orlp Sure. Need to go to bed though 2:35am
 
__restrict__
dno if it matters
 
Anyone know off-hand if "#define private public" has any problems with compilers other than MSVC? Or if there's some hidden gotcha reason I shouldn't be using it?
 
None of those should affect 0x2208 though.
 
1:36 AM
@JerryCoffin Yeah. But I’m completely blind and somehow missed that there is also a white-list, all listed in the just preceding Annex E.1. And it’s disallowed.
 
@Pris Stop trolling.
 
@LucDanton Oops.
 
They call it C/C++ - it's justified. — Joseph Mansfield Oct 2 '12 at 15:23
lol
 
@orlp ?
 
@orlp looks basically the same; I did have an outlier ~1.4GB/s though. So it could be /slightly/ higher depending on scheduling priorities etc.
 
1:38 AM
nah it probably doesn't matter
I'll look at assembly output myself
 
@orlp I'd say insignificant. But, you might as well include it
 
@DonLarynx Private vs. public affects accessibility, not scope.
 
@sehe nah, __restrict__ is unportable
 
impotable
 
@DonLarynx Since it looks like you're still fiddling with code to parse a double, I finished off the code I wrote the other night. coliru.stacked-crooked.com/a/b8d5ec9b995e1e0f
 
1:42 AM
No NaN, +Inf and -Inf?
(lel)
@orlp Anyhoops, in case you want to compare notes: gist.github.com/sehe/383928acc07d0a3daa99 (includes a 100Mb data file...)
 
@sehe the king of overengineering :D
cloning and running benchmark
 
@sehe Nope--though I guess I could add them too, this was intended to parse numbers and NaN (in particular) doesn't qualify.
 
@sehe 100MB clone it is
 
@JerryCoffin I knows
@orlp The md5sum of the hex output should be 70fbdb6a157caa1905becbafe1934581 (an preferrably in ~1/10th second). Assumes lower case hex form
 
zzzzzzzzz
spirit takes forever to compile
 
1:46 AM
I hungriness, need ate
 
@sehe Yeah, I figured you must know what NaN stands for by now (but there are times I seem to forget).
 
I had no context. A double parser should, arguably, include it
A number parser, obviously, doesn't care
 
@sehe what is pv?
 
@orlp it will end some time. The speed was really disappointing there.
 
@sehe Probably, now that you mention it.
 
1:47 AM
@orlp Oh, pipeview
Night all
 
golly
 
@sehe G'night.
 
trie-spirit is so slow
 
Too I sleeping need
What do? Sleeps or eaten?
 
@Jefffrey Eat, then sleep (then eat again).
 
1:52 AM
Sounds like a good idea.
 
@sehe Cya! N8 ...
 
@Jefffrey Eating is always a good idea.
 
@sehe dno, on my machine I was fastest from the get-go gist.github.com/orlp/4629a30fc92d620f92fe
 
@JerryCoffin She's likely going to like it :) ...
 
2:13 AM
Guys, did you know it's tongue awareness month?
 
Why does my phone allow me to send an empty Sms?
 
@orlp i thought it was breathing awareness month?
 
@chmod711telkitty It's just similar to a Ping, it should allow you to do this.
 
I accidentally sent someone an empty Sms & was asked why I did it ...
 
> I wanted to see how far away the ping was audible
then follow up with
> you passed the test ;)
 
2:26 AM
@chmod711telkitty "... & was asked why ..." Well, that's one of the questions you should be prepared of, when pinging!
@orlp When it'll going to be clit awareness month finally?
 
@JerryCoffin If the data is inaccessible, the data implicitly has no scope. Conversely, if the data has no scope, then the data isn't defined in the scope. It's implicitly inaccessible. Therefore, since private data isn't accessible unless a friend function was called or if you are inside of the class, private data has class scope.
 
@orlp ^parental advisory: explicit speech
 
wat
@πάνταῥεῖ Unnecessary, uncalled for, un- everything
 
@DonLarynx Because you don't call for it, that doesn't mean I don't say it!
 
@πάνταῥεῖ But you did say it, invalidating your entire argument.
> Please note that the standard is not intended to teach how to use C++. Rather, it is an international treaty – a formal, legal, and sometimes mind-numbingly detailed technical document intended primarily for people writing C++ compilers and standard library implementations.
 
2:36 AM
@DonLarynx I don't see invalidating myself, bringing in the ladies' view ...
 
@DonLarynx Not really. Scope governs visibility of a name. Accessibility is orthogonal to that. For example, consider this code: coliru.stacked-crooked.com/a/7b636333283916dd. In it, bad::f(double) isn't accessible, but is in scope in main, so the call to b.f(1.23) resolves to it, but compilation fails, because it's not accessible. If it wasn't in scope, compilation would succeed, because then the call would resolve to bad::f(int), which is accessible.
@orlp A little testing on my machine here at work seems to show your second and last versions, and my version effectively tied--more variation between runs of the same program than between the different programs. All the others seem at least a little bit slower (tested with both VC++ and g++).
 
2:54 AM
After some investigation the allowed code points are actually fairly lenient. Best as I can tell it’s punctuation and operators that’s excluded.
Somehow though there’s INVISIBLE TIMES and PLUS.
I thought I could annotate the handful of ranges that were allowed. Big mistake. Too many Unicode blocks to bother.
 
@LucDanton Maybe Bjarne's paper about overloading whitespace wasn't entirely a joke... :-)
 
Anyway the Standard goes out of its way to allow ZERO WIDTH SPACE which is blacklisted by browsers due to the phishing potential in URLs. Obviously that means we have to use it.
@JerryCoffin lol!
 
user3010322
@Borgleader It looks like GLSLang (Khronos' reference compiler) can take GLSL and turn it into an AST, and they've already got experimental SPIR-V support in there. This means GLSL is all but done when it comes to parsing it using GLSLANG, albeit there's a handful of extensions there (but really, I don't care about these extensions).
 
user3010322
Now it's just a matter of picking through exisiting HLSL compilers and HLSL Bytecode compilers and seeing if I can embed those in my application (or just making my own), and then I'll be able to sit down and just write in whatever shading language I so damn please (and freely convert between the two at runtime with an optimizing compiler).
 
> A static object is a class all of whose members (functions and data) are declared static.
 
3:11 AM
Anyone helping to handle this guy/lady?
@LaVloZ _" I know that !!! "_Well fine, and what you are asking about actually now? If you try to compare apples with oranges regarding the better looking, what answer would you expect? — πάντα ῥεῖ 1 min ago
-2
Q: Best practice static C function or private C++ method

La VloZI'm a Java developper but now i have some a little work in C++ and i want to know which is the best in C++ between static C functions and private C++ methods. I know that static C functions are used only in the current file and private C++ methods are used only in the current class, but what sho...

 
I have a const static type id counter. It has a unique value for every unique type for a class template. So, if I had Thing<A> and Thing<B>, the type ids would be 1 and 2. I do this by calling '++' on another global variable. Is there any way I can stop compilation if the max type id exceeds some number? I'm trying to use static_assert but I get 'not initialized with a constant expression' errors.
 
No mutation in non-function-local constexpr. So if are ever incrementing something, static_assert cannot possibly achieve what you want.
 
All the incremented values should be calculated by the time compilation is finished :/
 
3:26 AM
That’s not true.
 
Wow.
 
linking
 
I'm not sure if I'm fucking insane
But Python can't handle my valid UTF-8.
 
@Pris That’s not true either. The compiler doesn’t compute anything. You do raise a good point though: what about dynamically linked stuff?
 
I'm so confused :(
 
3:29 AM
@Pris Consider: if you write and compile the program int main() { int the_answer = 42 + 0; } by the time the binary is produced nothing has been computed.
 
>>> x = u'\u30C1'
>>> x.encode('utf-8')
'\xe3\x83\x81'
 
If and when you do run the program, then the_answer is computed.
 
yet in my actual program it complains about 0x81
how2sscce
 
@Rapptz block comment all the things
 
that won't do
 
3:32 AM
@Rapptz Python program?
 
yeah
I can't reproduce it.
>>> import codecs
>>> f = codecs.open('test.txt', 'w', 'utf-8')
>>> f.write(x)
>>> f.close()
>>> f = codecs.open('test.txt', 'r', 'utf-8')
>>> f.read()
u'\u30c1'
>>> f.close()
>>> x
u'\u30c1'
hmm
 
> Is it appropriate to access a class' private members by casting it to a void pointer and then to a struct?
> No. What you are doing is Pure Evil.
Morans....
 
@LucDanton Are the following values also determined at run time? coliru.stacked-crooked.com/a/ec7f8ab3229c931b
I was hoping to prevent compilation if the total number of type indexes went above a certain limit, but I guess I have to use a run time assert or something
 
@Pris Yes.
constexpr is the tool to ensure that a value is available at compile-time.
Note that you can’t mutate variables declared constexpr (it implies that the variable is delared const).
 
Holy smokes DevLeague is awesome
Just got off work
 
3:48 AM
Dear Lord. You gotta ask yourself "what if".
 
@Jefffrey Indeed
Operator () a thing? Lol
 
I knew escape_multi_byte would come in handy one day.
Suck it
Properly escaped too.
 
what the fuc
auto add(T t, U u) -> decltype(t + u) // the return type is the type of operator+(T,U)
{
    return t + u;
}
what the fuc is the -> for
 
@DonLarynx return type
 

« first day (1620 days earlier)      last day (3311 days later) »