« first day (711 days earlier)      last day (4251 days later) » 

3:00 PM
@CatPlusPlus dafuq, you follow another chat? this is a crime, my friend
 
There is only ONE chat!
 
@Cheersandhth.-Alf Soddin' moron. How the fuck are we supposed to test shit like that? Codez...
 
I now own Gratuitous Space Battles
 
I was star whoring.
2
you bastards
 
@MartinJames no, he was just having a bit of fun. i believe. :-)
 
3:02 PM
@DeadMG I now own two copies of Gratuitous Space Battles. Fuck the HIB, always adding dupes as the extra extras.
 
@TonyTheLion I know. I used my WhoreOVision.
 
@DeadMG you starred the wrong thing!
2
 
And two copies of BIT.TRIP RUNNER, and two copies of Jamestown.
 
@TonyTheLion I didn't star it.
 
And three copies of Super Meat Boy.
It's dupes all the way down.
 
3:03 PM
0
Q: With an example, explain why C is advantageous over C++ ?

Ajith SimhaWhy did C programming jump to the 1st place in Tiobe index? I havent found the exact answer for this question. I want the answer as simple as possible. Your answer must be understandable for a beginner too. Waiting for the reply.

 
@R.MartinhoFernandes Your chat profile says 50.6k
 
@Cheersandhth.-Alf WTF? You mean it's OK to post the code I'm working on on SO, ask for help, (impossible), and get points/start/rep for it?
 
Your SO profile is ~50.7k
 
I only grabbed a couple of HIBs but I'm pretty sure that I've no duplicates yet
 
user784668
@jornak Chat profile updates only when you enter the chat.
 
3:04 PM
@jornak That's reputation.
 
@MartinJames That dude most definitely lost rep.
 
@Fanael Ah, okay.
 
We were talking about messages/week.
 
@MartinJames sure. have you tried it?
 
@R.MartinhoFernandes No, I know that, but you said "@DeadMG Woah, woah, where did I get that reputation?"
 
3:05 PM
@Cheersandhth.-Alf No, do you think I should do? (sensing trap here)
 
And I was noting the discrepancy between your chat and SO profile, until Fanael cleared it up
 
@jornak Ah, I was talking about actual reputation, as in, what other people think of me (namely, that I am a backstabber), not imaginary Internet dollar points.
 
@R.MartinhoFernandes Oh <_<
 
People ask some weird SO questions sometimes.
 
@R.MartinhoFernandes Not a backstabber. Just a plain psychopathic axe/knife murderer.
 
3:05 PM
Disclaimer: I'm not a backstabber. Nor a psychopathic axe/knife murderer.
 
@MartinJames well no trap, but it's a good idea to be sure employer OKs posting code here
 
Seriously, I'd probably cut myself if I tried to murder someone with a knife.
 
@R.MartinhoFernandes Just a normal axe/knife murderer, right?
 
it can be difficult to remove stuff from SO
 
@jornak Or sociopathic!
or maybe he could also be schizophrenic, or delusional
 
3:06 PM
@DeadMG Sociopathy is overrated
 
yeah, cause people want to be sociopaths, right? :P
 
jeff has done that, but only in case of a somewhat intellectually challenged (ADHD?) girl
 
@R.MartinhoFernandes True, you're just a killer at C++.
 
@DeadMG Sociopaths make great programmers.
 
@jornak I've never fully figured out the difference between Sociopath and a Psychopath. In fact for a long time I assumed they were nearly one in the same.
 
3:07 PM
@R.MartinhoFernandes not until you get caught at least... and they decide that robots can be sentenced
 
@Cheersandhth.-Alf Wait, do I have vague memories of... Tina, was it?
 
@ThePhD Social disorders, psycho = erratic, socio = controlled
 
@DeadMG right
 
@Cheersandhth.-Alf That would be no problem, it's all someone else's shit, it's full of magic numbers and logical operator crap and cannot possilby be used debugged without a complete system with special hardware. Sounds ideal for a post.
 
Sociopaths also appear normal in their everyday relationships
 
3:08 PM
he he
 
Psychopaths tend to stand out
 
i'd go for it :-)
 
@ThePhD Psychopaths are people that feel no (or very shallow) emotions. Sociopaths have anti-social tendencies.
 
So Psychopaths are infinitely more dangerous?
 
@ThePhD Yes and no.
A psychopathic murderer will tend to leave clues as their behaviour is erratic, and therefore get caught quicker... but would probably do more damage.
Sociopaths are controlled and tend to leave no evidence.
Sociopaths are... wired incorrectly.
They do feel emotions, just not the way "normal" people do.
 
3:10 PM
I don't know where you got the erratic part from, but that's not what I was taught.
 
@DeadMG don't mention her...
 
At last, a word to describe my test network - Sociopathic
 
AFAIK sociopaths have very low thresholds for initiating violence, which does not fit with the "controlled" bits at all.
 
Psychopaths tend to be compulsive, fearless, etc
 
the term "psycopath" was removed as clinical diagnosis for i think it was close to 10 years?
 
3:11 PM
@ThePhD is a sling shot more deadly then a knife?
 
it's back again now, as I understand it
 
@Cheersandhth.-Alf It's still used in criminal circles.
 
@thecoshman Well, if you want to be biblical, Goliath got pwned by a Slingshot. So yeah, if someone came at me with a Slingshot, I'd piss myself.
 
It's just a difference between outward behaviour, really
 
i think main characteristic is lack of empathy (ability to feel what someone feels)
there are some interesting facts
 
3:12 PM
@Cheersandhth.-Alf Yeah, that's what I thought too.
 
Most psychiatrists won't say there's a difference between socio- and psychopathy
 
@ThePhD yet if I was holding a knife to your throat?
 
It's the criminologists that do
 
like, psychopaths are not fooled by visual what-it-called hollow mask
 
@thecoshman Still pissing myself. THe hope was I wouldn't let it get to the point where you'd get that close.
 
3:13 PM
other people think it's outside of a face
psycho see the mask as it is, inside of a face
 
@thecoshman I'd shoot you.
 
@Cheersandhth.-Alf When did we bring Bleach into the mix? ;)
 
Shooting people can always solve problems.
4
 
@thecoshman However I can't really avoid slingshot shots, unless I know/see it's coming.
 
@R.MartinhoFernandes moot point
 
3:14 PM
The great thing about a knife is that it's still in melee range. If you know what you're doing you can fight/run/scamper out of it.
 
@thecoshman No, hollow point.
 
@thecoshman Depends.. a slingshot has a greater accurate range than a knife, (which is very difficult to throw accurately), but is a hopless close-quarters weapon and a kill is very difficult. Knife - 50% kill rate.
 
It's also that much of a terrible thing: there's a -fucking- KNIFE in Melee range of your organs.
 
@ThePhD people can throw nifes rather well
@R.MartinhoFernandes difference?
 
3:15 PM
@LuchianGrigore 404.
 
@thecoshman Hollow point disrupts more tissue. (i.e., it was a joke)
 
@MartinJames my point was mostly that like the original example, there are far to many factors at play
 
@jornak for you, maybe :P
 
@R.MartinhoFernandes ooh, bullets, I see what you did now
 
@thecoshman It's escalating. Is it time for the iTunes nuke yet?
 
3:16 PM
@thecoshman I'd take my statistical chances in that far less people know how to throw knives than how to stab somebody.
 
Xeo
Oh hey, the Funatics guys sent a message
 
@Xeo See, I told you you were overreacting.
I didn't, but I like saying "I told you so".
 
Xeo
Not really
 
@Xeo Is it a message you can't refuse?
 
Xeo
He still couldn't discuss my application since is Wife is very pregnant (yes, that seems to be the medical term...) and he scheduled a takeover of my application by a colleague for tomorrow morning.
Now, how to politely express that I'm very pressed for time since I have another offer that I've been pushing back because I'd rather work for them?
 
3:19 PM
Very pregnant? lol Does that mean close to 9-months pregnant, or pregnant with multiple twins?
 
any way, I think I might start a slow walk for the bus...
 
@Xeo "I don't have time, motherfuckers." I suck at this.
 
Xeo
@R.MartinhoFernandes Should be close to 9 month
 
@R.MartinhoFernandes parallel pregnancy
 
Xeo
In German it's "hochschwanger"
 
3:20 PM
@thecoshman Multi-threaded fetus development?
 
in Dutch its "hoogzwanger"
 
Xeo
Oh, correct usage for "hochschwanger sein" seems to be "to be in the late stages of pregnancy" :)
 
@ThePhD ಠ_ಠ
 
@Xeo "sein" is a form of "to be"?
 
Fetus Level Parallellism
@R.MartinhoFernandes yes
 
3:21 PM
@thecoshman Just sayin'. That's like what it'd be like having Twins or Triplets or Quadruplets.
 
Xeo
@R.MartinhoFernandes Aye
 
user784668
Single Instruction, Multiple Fetuses.
 
@ThePhD If they're identical twins, it's single-threaded, as there's only one egg.
 
@R.MartinhoFernandes Neato!
 
@R.MartinhoFernandes That would be fetus level parallelism then
 
3:22 PM
I gotta go now to buy more external disk for my loopless fizzbuzz implementation. I've been copy/pasting for four hours now and have no disk left.
 
Does the C++ standard define "strict aliasing" or is that a C99 thing?
 
Xeo
"Ich bin, du bist, er ist, sie sind" are all forms of "sein", in English "I am, you are, he is, they are"
 
@StackedCrooked Yes, it's defined by the C++ Standard.
 
@StackedCrooked I don't think it uses that term.
 
user784668
@StackedCrooked It does, but it doesn't call it "strict aliasing".
 
3:22 PM
Ich bin Wumboing.
 
@R.MartinhoFernandes sein: Ich bin, Du bist, Er ist, Sie ist, Es ist
that's the singular form
 
It merely forbids violating it, without naming it.
 
Xeo
@DeadMG No matches in the pdf :)
 
@DeadMG no, the term does not appear in the standard
 
user784668
@R.MartinhoFernandes sein is the infinitive.
 
3:23 PM
they can't use the C99 wording because surely it needs to be altered for inheritance?
ah, whatever
 
furthermore, c++11 was fixed with an (ugly) kludge to remove the most obvious self-contradiction in the list
 
IIRC casting T* to char* is allowed because char* is byte-aligned. Does that mean I allowed to write to data pointed to by char* and then read from T* and vice-versa?
 
Alright.
So I think I've blwon up
or privately-inherited
all STL containers and templates
 
user784668
@Cheersandhth.-Alf "fixed (…) kludge" pick one.
 
Save for String, but. I can't really help that.
 
3:24 PM
@StackedCrooked Yes. You can alias any type with char*.
 
@StackedCrooked Don't expect portable results, though (except in very specific cases).
 
@Fanael it depends on how natural you find it to regard e.g. double as a most derived class
 
However, I can't cast char* to T* right?
 
since it manifestly isn't a class
 
I think you can cast char* to T* with sufficient parenthesis.
 
user784668
3:25 PM
@Cheersandhth.-Alf A kludge then, therefore not fixed.
 
@StackedCrooked You can.
 
((T*)acharpointer)
 
0
Q: How to convert large number of uint_8 into array of floats in C?

xiongtxI'm reading (in binary format) a file of unsigned 8-bit integers, which I then need to convert to an array of floats. Normally I'd just do something like the following: uint8_t *s1_tmp = (uint8_t *)malloc(sizeof(uint8_t)*num_elements); float *s1 = (float *)malloc(sizeof(float)*num_elements); fr...

 
C-style cast bad
 
user784668
3:26 PM
@ThePhD Please die.
 
a question for @Mysticial
 
=[
 
@Fanael And then I'm the one that wants to murder everyone!
 
@Fanael I'm sorry. How should I be casting?
 
3:26 PM
@DeadMG char c[4]; int * n = reinterpret_cast<int*>(&c[0]); // OK?
 
@StackedCrooked Should be.
but as you might imagine, the slightest mis step and UB.
 
user784668
@ThePhD Don't cast at all. If you have to, pick your poison: static_cast, dynamic_cast, const_cast, reinterpret_cast.
 
Isn't re-interpret casting mostly the same as just C-style casting?
 
user784668
@ThePhD No.
 
<--- Noob is showing.
... I do so much C-Style casting...
 
3:28 PM
you noob
you should be flogged :P
 
@ThePhD Not at all. The allowed reinterpret_casts are quite limited. C-style casts can do lots of stuff.
 
Suppose I have a point and size types: struct point { int x, y; }; struct size { int width, height; }. Can I alias them if I use an intermediate char*?
 
508
A: When should static_cast, dynamic_cast and reinterpret_cast be used?

copprostatic_cast is the first cast you should attempt to use. It does things like implicit conversions between types (such as int to float, or pointer to void*), and it can also call explicit conversion functions (or implicit ones). In many cases, explicitly stating static_cast isn't necessary, but it...

 
I dunno. It just seemed most natural to use that stuff when doing manipulations over large arrays on generic types.
 
@StackedCrooked No.
 
user784668
3:29 PM
@StackedCrooked No, that's UB.
 
CppProgrammer Tony = reinterpret_cast<CppProgrammer >(TonyDOTNET);
 
@DeadMG Even if they have identical object layouts?
 
I did that cast on myself a while back
 
@StackedCrooked Yep.
 
@TonyTheLion lol
 
3:30 PM
@StackedCrooked There's an exception for common starting sequences of whatever the standardese is.
 
if you have point p; then any pointer with the same address as &p which does not have the type point* or char* is immediately UB.
the new standard layout stuff might have changed that, though, I wasn't paying too much attention
 
@TonyTheLion You program in the C pre-processor?
 
@R.MartinhoFernandes Is it Turing-Complete?
 
What is UB?
 
3:31 PM
// what about:
char c[sizeof(point)];
point * p = reinterpret_cast<point*>(&c[0]);
size * s = reinterpret_cast<size*>(&c[0]);
 
user784668
@ThePhD Undefined behavior.
 
@DeadMG Not really. int* should work too (you can alias as the first member), and I think size would work too because they share a starting sequence. I'll check that last bit in the standard.
 
@Fanael Ah.
 
@StackedCrooked Pretty sure that's still UB.
@R.MartinhoFernandes Never heard of the starting sequence thing, but you're right about int*.
 
@StackedCrooked Call me crazy, but that looks fine to me.
 
user784668
3:33 PM
@ThePhD You're crazy and wrong.
 
@StackedCrooked Though now I'm thinking endianess might punch you in the face later?
@Fanael Oh, well then okay.
 
Ah, found it.
 
@ThePhD No that won't be a problem.
 
@ThePhD no, pointer aliasing
 
> If a standard-layout union contains two or more standard-layout structs that share a common initial sequence, and if the standard-layout union object currently contains one of these standard-layout structs, it is permitted to inspect the common initial part of any of them.
Two standard-layout structs share a common initial sequence if corresponding members have layout-compatible types and either neither member is a bit-field or both are bit-fields with the same width for a sequence of one or more initial members.
@StackedCrooked you can go from look at a point through a size* if you put 'em in an union.
 
3:34 PM
@R.MartinhoFernandes I see.
@R.MartinhoFernandes And my sample code above is still invalid then?
 
@StackedCrooked I can't find "common initial sequence" anywhere else, so I'm going with yes.
 
user784668
@R.MartinhoFernandes Have they really changed that?
 
Going home now, brb.
 
@Fanael It's in §9.2/18 if you're curious. (I don't know if it's a change; I only started learning C++ after the FDIS came out)
 
standard layout is new in C++11
 
3:37 PM
It could have used POD before.
All usages of POD in the standard are pretty much gone now; they stick with the minimal requirement of trivial or standard layout, as appropriate.
 
I'm so glad you guys are here.
I'd give people some really bad advice.
 
You know what's silly, though? These kinds of UB with reinterpret_cast are detectable at compile time. At least warnable.
 
user784668
@ThePhD So you should burn in heaven.
 
@Fanael Indeed. I shame my famiry.
 
3:41 PM
what's happening bustas
 
point p;
auto i = reinterpret_cast<int*>(&p); // compiler knows first member is int, so ok
auto c = reinterpret_cast<char*>(&p); // chars are ok
auto d = reinterpret_cast<double*>(&p); // compiler knows first member is not double, and &p is not double*; why doesn't it freak out?
 
@R.MartinhoFernandes because compilers don't know how to freak out?
you should know that, you're a robot :P
freak_out() is not implemented
 
@TonyTheLion Oh trust me, they do.
Sep 1 at 16:27, by R. Martinho Fernandes
I think I had my dosage of fun while I was chewing down on those 18k errors the other day.
 
oh gawd.
 
@R.MartinhoFernandes Because reinterpret_cast?
The entire point of which is to tell the compiler "shut up I'm smarter than you"
 
3:44 PM
@Collin But the point is, in this case you're not, because you're invoking UB.
 
@R.MartinhoFernandes And the compiler can prove it, is the important point :P
 
@R.MartinhoFernandes if you use reinterpret_cast in a position where the compiler wouldn't freak out, then you probably didn't want reinterpret_cast
 
@R.MartinhoFernandes Because the whole point of reinterpret_cast is to tell the compiler not to freak out. Could/can be useful when/if (for one example) you receive a buffer of data over a network, and what the compiler "knows" is just chars really represents a double, so you use reinterpret_cast to let you see it as a double.
 
Exactly.
@JerryCoffin But char* -> double* is fine. point* -> double* isn't.
 
@R.MartinhoFernandes Is static cast ok with casting to the aliased pointer? That I think would be the "right" think to work
 
3:46 PM
@MooingDuck Yes, you would. See Jerry's textbook example.
 
@R.MartinhoFernandes So? What about IP_packet * to double *?
 
Xeo
@R.MartinhoFernandes In this case, it's questionable why the compiler doesn't freak out.
However, in the general case, you could've reinterpret_casted to`point*` at some other place
 
@JerryCoffin Depends on IP_packet. If it doesn't have a double first member, that can only lead to UB, no?
 
Xeo
And maybe that was originally a double*
 
@Xeo No you couldn't, cause that would have been UB.
 
3:47 PM
@Xeo Not really. In an argument with a C++ compiler, the programmer can always have the last word, and reinterpret_cast is one way to get it.
 
@DeadMG I think you can "transport" the pointers safely if you don't touch the pointees.
FWIW, if you need to store a IP_packet* as a double* for legacy reasons (why else would you?), you can go through void* to shut up the compiler.
 
Xeo
> An object pointer can be explicitly converted to an object pointer of a different type
 
It undoubtedly does not have a double as its first member, but based on, for example, the content of some other packet we know that what it really contains is the "flattened" version of a double.
 
Emails from work:
"Our internet service provider has confirmed reported internet problems for the US West Coast and is working to resolve this issue."
Well that's not good.
 
Xeo
> When a prvalue v of type “pointer to T1” is converted to the type “pointer to cv T2”, the result is static_cast<cv T2*>(static_cast<cv void*>(v)) if both T1 and T2 are standard-layout types
 
3:50 PM
@Xeo That doesn't cover the aliasing bits.
 
Xeo
> Converting a prvalue of type “pointer to T1” to the type “pointer to T2” (where T1 and T2 are object types and where the alignment requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer value. The result of any other such pointer conversion is unspecified.
Note that the casting in and of itself is never undefined behaviour.
The result is only unspecified
Dereferencing a wrongly casted pointer is UB however
 
@Xeo Yes, that means you can convert IP_packet* to double* for transportation. Nothing else.
My argument is, why do we want that?
 
... I'm confused now. Just, if you're using basic Primitive data types, like int double short etc., shouldn't any struct made out of purely primitive data types (sans aligning) be castable to one another?
 
Especially since that functionality is redundant with static_cast through void*.
 
Xeo
@R.MartinhoFernandes Who knows, but it's always been C++'s argument that you can do what you want if you really want to.
 
3:52 PM
@ThePhD No.
 
Xeo
@ThePhD If they're layout-compatible
 
@Xeo Right. If you really want to, take the long road: pair of static casts.
Which, btw, is better than reinterpret_cast.
 
Xeo
@R.MartinhoFernandes Then, I wonder why reinterpret_cast is specified in that pair of static_casts only when the types are standard-layout types
 
reinterpret_cast<non_pod1*>("blahblah"); is UB (and no compiler I know of freaks out on this either). static_cast<non_pod1*>(static_cast<void*>("blahblah")) isn't.
 
Xeo
@R.MartinhoFernandes The first is not UB.
> The result of any other such pointer conversion is unspecified.
 
3:54 PM
Hm.
 
@Xeo Oh, well. Not that it helps much.
 
Xeo
@R.MartinhoFernandes Wait, in this case, the first is UB I think, since you cast an lvalue to a pointer type
 
It still makes it worthless since you can get well-defined behaviour with static casts.
@Xeo Meh, make it &""[0] if that matters.
 
Xeo
Hm, actually, it doesn't eve say that
> An lvalue expression of type T1 can be cast to the type “reference to T2” if an expression of type “pointer to T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast.
gah, no, we're casting from reference type, not to
 
Don't worry about that. The string literal was just me looking for a quick way to get a pointer.
 
Xeo
3:57 PM
Now you got me wondering though. :P
Also, I think your first example isn't even unspecified
It's a cast from "pointer to T1" to "pointer to T2"
 
Ideally, reinterpret_cast would only allow those casts that are truly safe, like chars and first members and shit. For any of the weirdnesses you have static_casts and void*.
@Xeo Of non-standard-layout types (one of them).
 
I'm going home
today was a bad day
 
Xeo
@R.MartinhoFernandes Second point covers that
 
freakin' sony and their f***ed up compiling...
 
Xeo
9 mins ago, by Xeo
> Converting a prvalue of type “pointer to T1” to the type “pointer to T2” (where T1 and T2 are object types and where the alignment requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer value. The result of any other such pointer conversion is unspecified.
the first part here
 

« first day (711 days earlier)      last day (4251 days later) »