« first day (862 days earlier)      last day (4071 days later) » 

6:00 PM
@StackedCrooked Because Java copied C++ in this respect, and C# copied Java. And neither James nor Anders read TD&E, I suppose.
 
Ell
ruby has initialize. But it should be construct because z/s (imho)
 
What does z/s mean?
 
zorro/superman
 
zee suckage
 
@R.MartinhoFernandes the token sequence is C++14
maximal munch
 
Ell
6:04 PM
@FredOverflow I mean because "initialize" or "initialise". I know it's not a big issue but "construct" would avoid this
 
@Ell Aah.
 
@FredOverflow Which just repeats what most of us already knew: Java and C# kept most of the worst parts of C++ (especially the syntax) while throwing away most of the best (especially templates).
 
0
Q: Why Does Valgrind Hate Me

user1427661I'm messing around with allocating and deallocating memory to get the hang of it. Below, I take in string arguments from the command line (char **argv) and try to duplicate them as uppercase strings in another malloc'd array: static char **duplicateArgs(int argc, char **argv) { if (argc <...

^^ nice title...
 
@JohannesSchaub-litb So, basically, the question is whether any part of the grammar allows <identifier><increment><integer literal>?
 
@JohannesSchaub-litb If I have to lex it myself, I don't think it counts as a token sequence.
 
6:08 PM
@JerryCoffin whether there is a valid c++ program that contains these tokens in that order directly after each other. no macros are allowed
 
@JohannesSchaub-litb Why do you care about stuff like this?
 
@R.MartinhoFernandes C is a token, ++ is and 14 is a token
@FredOverflow research
 
Now we are getting somewhere.
 
I'm gonna go with "no".
 
@JohannesSchaub-litb Hey, if postfix ++ takes an additional int parameter, shouldn't it be able to accept the int 14? ;-)
 
++C prefix increment
C++ postfix increment
C++14 postfix increment in C++14
 
Ell
Awesome webgl stuff makes me want to write a game in js xD
 
Mmm, delicious javascript.
 
lol @FredOverflow
here is the solution
#if 0
   C++14
#endif
int main() {}
 
That's lame.
 
6:14 PM
Tsk you still haven't learned
 
lol @FredOverflow
 
Mmmmmm
Fresh new linker erro- ...
.. .Wait, this is some kind of strange warning.
warning C4506: no definition for inline function 'Furrovine::uint32 Furrovine::BitMathema::NextPow2(Furrovine::uint32)'
Guess... I shouldn't mark it as inline, then..?
 
Did you mark it as inline without a definition? :-)
 
I've got it defined elsewhere in another file (exports to a DLL)
This error happens in the client project only.
When building the DLL it exports fine enough..
 
inline is meaningless for not-defined functions
 
6:20 PM
So inline is not supposed to go on declarations?
 
@CatPlusPlus But shouldn't cause a warning either
 
Yes, it should
 
@n2liquid Warning or error?
 
@ThePhD As long as you define it later in the same header it will work.
 
Uh, yeah
 
6:21 PM
@FredOverflow Doesn't matter with Werror.
 
Error
 
@ThePhD It's used to get around ODR, so there's absolutely no point using it on something that's not affected by ODR
 
What will work? inline is ignored by modern compilers, anyway. Isn't it?
 
@ThePhD if it's not defined in the same transaltion unit, why are you marking it as inline?
 
... Oh. So inline only goes on... declarations?
definitions* /
 
6:22 PM
@FredOverflow It's ignored as far as inlining is concerned
 
@CatPlusPlus right
 
@n2liquid The DLL is currently being Unity-Built. E.G.:
 
So don't write inline if your intent is inlining. The compiler will ignore it.
 
#include <Furrovine++/BitMathema.Decl.h>
#include <Furrovine++/BitMathema.inl>
.Decl is - obviously - only the declaration of the struct.
 
Write inline if you wanna define your function in a header
 
6:23 PM
.inl is the definition, like a regular .cpp definition.
 
do not use static easy error to make
 
@JohannesSchaub-litb And if its in a class?
 
then write nothing
 
.... Nothing? o_O;
 
@ThePhD Why do you insist on writing inline? Who taught you this habit?
 
6:24 PM
Member functions defined inside class definition are inline by default
 
the goal is to make it an inline function. a member function defined in its class body is automatically an inline function
 
user142019
Window y u no border.
 
without you writing the inline keyword for it
 
@JohannesSchaub-litb He wants to separate the declaration from the definition, but still have it inline for some reason.
 
That sounds great, but that's not the way it behaved....
 
6:25 PM
@FredOverflow that's a mistake I think
 
Before, when I was not inlining anything and I tried to use my declaration-and-definition structs/classes, the compiler complained about multiply defined symbols.
 
@JohannesSchaub-litb I agree.
 
The only thing inline changes is whether you can repeat definition in multiple TUs
 
@ThePhD It shouldn't. You have done something else wrong. Did you forget header guards?
 
if inlining is the goal, he could use some special attribute like always_inline, which is implementation specific
 
6:25 PM
@ThePhD Definitions were outside of the class
 
otherwise, writing "inline" for that purpose is totally redundant
 
Do you guys know a comprehensive guide / paper / article on the state of inline for modern compilers? Like, how to achieve it, why the inline keyword is getting ignored nowadays, and how do compilers know they can inline a function?
 
@FredOverflow No, I didn't forget header guards...
... I'm so blisteringly confused.
 
struct foo { void x() {} /* inline */ };
struct foo { void x(); }; void foo::x() { } /* not inline */
 
@n2liquid That's extremely implementation-specific.
 
6:26 PM
@n2liquid They know
 
@ThePhD Show us the original error message. You probably defined global variables or top-level functions in header files or something.
 
@FredOverflow What does the standard say? I used to think of inline as a programmer giving the compiler "permission to inline" or something
 
Standard doesn't say anything about inlining
 
@n2liquid That was the case back waaayyyyy back before C++ compilers stopped sucking completely.
 
@CatPlusPlus So the inline keyword is by standard a "no-op" keyword just to avoid breaking backwards-compat?
 
6:28 PM
You can let GCC print a warning if it decides to not inline a function.
 
Do we have a FAQ on what goes in header and what goes in cpp files?
 
Or was it never standard to begin with?
 
@FredOverflow I had that problem too, but it was separate: I solved it by marking global top-level functions as inline. The original error messages are lost; I didn't save those. The only error (warning) I'm getting now is the one about using inline in something that is not defined
 
@n2liquid No
 
putting a function in a header and marking it inline can save code space and make the executable smaller than marking it static
 
6:28 PM
@FredOverflow I read it already...
 
It's about ODR
 
some ppl don't believe that because they fail to understand the difference
 
@n2liquid It's used for ODR purposes only nowadays. You can define inline top-level functions in header files, for example.
 
@Bartek Ready when you are
 
Oh it does say something about inlining
 
6:30 PM
@ThePhD inline member functions without definitions in the same file don't make sense to me, and it seems your compiler agrees.
 
But it's not required, only semantics regarding ODR are
 
Rubs face.
Okay.
 
A function declaration (8.3.5, 9.3, 11.3) with an inline specifier declares an inline function . The inline
specifier indicates to the implementation that inline substitution of the function body at the point of call
is to be preferred to the usual function call mechanism. An implementation is not required to perform this
inline substitution at the point of call; however, even if this inline substitution is omitted, the other rules
for inline functions defined by 7.1.2 shall still be respected.
And compilers use heuristics to determine whether inlining is viable or not
 
@ThePhD Can you elaborate why you want inline member functions, but define them in another file?
 
note that C's rules are radically different
 
6:31 PM
Nobody cares about C
 
@ThePhD Rub it real good.
 
@ThePhD unless those functions are private, you are going to run into real troubles
 
Let's start from the top.
 
Previously, my declarations of my stuff in headers looked like this:
It was defined and declared in a header, all at the same time.
 
6:32 PM
And what was wrong with that? Most of those functions are pretty small.
 
Yeah that's inline
 
It was then exported to a DLL (Dll export statements removed for clarity)
 
You're dealing with MSVC extensions at that point
 
In a client project, I would use these functions in multiple translation units.
 
Oh, I know too little about DLLs :-(
 
6:33 PM
It complained about multiply defined symbols everywhere, for a lot of common functions.
 
@CatPlusPlus Ok, so if you declare something as inline, it affects ODR, essentially allowing the function to have multiple definitions... but if inline has no meaning to compilers today, then it might as well be ditched from the standard, since it bears no purpose; I mean, of course it affects ODR, but that has absolutely no purpose beyond... existing
 
you cannot use inline functions from different TUS unless each TU knows the definition
 
@ThePhD Why are you writing float Bottom () instead of float Bottom () const?
 
otherwise -> UB
 
Unless the purpose is to keep code backwards-compatible, which I think is the case...
 
6:33 PM
@n2liquid It allows the function to be defined in multiple TUs
 
@FredOverflow Typo, I'm fixing as I'm going.
 
The definition must be the same in all of them
 
In C, each can have a different defiintion
 
@CatPlusPlus Right; and is that useful for anything else but inlining?
 
@ThePhD How is omitting const a typo? Do you have a const key on your keyboard? :-)
 
6:34 PM
@n2liquid Yes
Header-only libraries
 
@CatPlusPlus Hm, true.
 
@n2liquid the compiler doesn't have to emit code for inline functions if they are not used in a TU
 
Inlining the function body at the call-site is a tradeoff optimisation and you're much better off leaving it to the compiler
 
Also, why void Size (const float& width, const float& height) instead of void Size (float width, float height)? Why on earth would you pass floats by const reference?
 
if they aren't used in any TU, no definition is emitted
 
6:35 PM
This is older code @___@
 
so arguably, an inline function saves code space even more than a non-inline function defined in a .cc file, potentially
 
I said I'm fixing it as I'm going, I haven't started on Physics yet and cleaned it all up
Goddamnit @____@
 
What are you programming, anyway? A game?
 
@ThePhD chillax, fred is only giving you a free codereview. That's a good thing.
 
No just some random DLLs
 
6:37 PM
q_q
 
@bamboon Yeah, I'm giving it to him for free xD
 
@EdwardBird Humour is fun but it should not take the place of a useful title. This is a programming Q&A and not a circus. — Lightness Races in Orbit 11 mins ago
 
Oh no Internet serious business
 
@FredOverflow Sorry. :c
 
@LightnessRacesinOrbit What's so funny about "Memory Leaks When Duplicating/Freeing Arrays"?
 
6:38 PM
@FredOverflow hard & fast
 
But in either case, seriously. The Lounge before told me to inline and split up my function definitions if I wanted to be able to include and use them in multiple TUs.
 
@ThePhD top-level functions or member functions? Huge difference!
 
every function is a member.
 
Top-level functions remained in their respective files and were inlinted.
 
6:39 PM
but only member functions are members of classes
 
@TonyTheLion That's a father? OMG.
 
Member functions and const static data members are marked with inline as well.
 
@R.MartinhoFernandes lol
@ThePhD WTF is inline const static data?
 
You can't inline variables
 
6:41 PM
Sorry, const static data members are marked for DLL export. ._.
English today my is suck. .__.
 
struct A { inline const static Data d;};
this can be valid
but not if you supply static
now it can be valid!
 
What is Data here?
 
It cannot be a function type, because those are not allowed here IIRC.
 
it cannot be valid in C++03, but only in C++11
@FredOverflow wrong!
 
6:42 PM
They are now allowed in C++11?
 
they are allowed to be const qualified in C++11, but the qualifier will be ignored
 
Oh wait, they are allowed in declarations, but not in definitions, right?
 
damn you @Cicada this stealing avatar business is just annoying
 
user142019
6:45 PM
Can cows swim?
 
Why do you ask?
Tan cos sin?
 
user142019
I'm wondering.
 
Well, cows fart a lot, so the gas would probably keep them afloat.
 
@Zoidberg yes, vertically.
 
up or down? xD
 
user142019
6:47 PM
 
@Cicada ready
 
@Bartek gonna eat right now
 
@BartekBanachewicz and with that, Gladiators is running through my head
 
@Cicada lol, ok. I've mentioned I'll be at 8 pm
 
alright. give me ~30 mins
 
6:51 PM
@thecoshman I am so gonna got beaten up
 
yes you are
 
@Cicada sure
 
(your build orders make no sense)
:<
 
uh
that's... well...
 
Ell
Ahh I so confused
 
6:52 PM
I am bad, alright?
 
Ell
Is that cat or cicada?
 
Look at the name.
Gravatars are decieving.
 
Look at the face
 
Ell
So are nicks xD
 
@BartekBanachewicz it's ok i'm not judging you
i just enjoy being mean
anyway brb
 
6:52 PM
eat fish.
(The origin of this quote has its beggining on WoW raid. long story)
I am going to warm up
 
user142019
 
user142019
lol 2:00.
 
oooh, tasty tasty dinner soon
 
user1182183
me too
 
user1182183
7:06 PM
;p
 
Ell
I'm having jacket potatoes
 
@CatPlusPlus Instead of changing a lot of the files at once I'm going to just translate them to .Decl.h and .inl iteratively. Should be a lot less of a mountain if I take little chunks out of it at a time...
 
Xeo
Man, I've been so productive today.
Slept till 12, did... something til 4, and slept till 8 (now) again.
 
user142019
That's not productive.
 
user142019
Stop lying.
 
user142019
7:09 PM
As in, lying on a bed.
 
@Xeo do coursera... it makes me feel like you just worse... like in college... always late, doing hw in the last moment :D
idk if you are still in college
 
huh
 
user142019
Unfortunately, yes.
 
you can't override a virtual function with an incomplete type?
ah well, I'll have to get on and include that LLVM header
 
@Xeo 4 hour wank session, my god you must be tender
4
 
user142019
7:11 PM
lol
 
user142019
Why isn't it possible to put typename before any type name?
 
what do you mean?
 
@Zoidberg you are probably confusing the tmp compiler machinery ...
 
@thecoshman typename int x;
 
user142019
typename std::enable_if<x, myclass>::type foo; // ok; type is dependent
typename myclass foo; // error; myclass is not dependent
 
user142019
7:18 PM
But isn't that a pointless restriction?
 
Xeo
@thecoshman lol
 
@thecoshman tender is "raw"?
 
Xeo
That restriction was removed in C++11, IIRC?
 
@sehe more or less
 
Xeo
No idea why it's not allowed for top-level, but eh, who cares.
 
user142019
This makes code generation more bearable. xD
 
^^ how does that work!?
i wanna have that "sound light" too
 
@JohannesSchaub-litb it's simple dude
 
7:25 PM
hmm
 
it's just pulsing the tesla coil at frequencies that result in audible music as it crackles
it's roughly how AM radios work
 
hmmm
 
> Cats have an attitude, you know? They think they're the coolest... cats around.
lol
 
and you can use them to make speakers, apparently they can produce some of the cleanest sounds, but they lack the bass
 
@Zoidberg Didn't C++11 lift some of these restrictions?
 
user142019
7:30 PM
10 mins ago, by Xeo
That restriction was removed in C++11, IIRC?
 
9 mins ago, by Xeo
Ah, for nested names, I mean
 
@FredOverflow That's not the original title.
 
Xeo
I'm being quoted! I'm famous! It's only a matter of time until they print books about me!
3
 
Sorry, switching back and forth between the Lounge and the FP room gets me confused :)
@LightnessRacesinOrbit What is the original title?
 
@FredOverflow It was "Why does Valgrind hate me?" or somesuch
 
7:31 PM
@FredOverflow fp?
 
@thecoshman FP
 
user142019
FAP FTFY
 
you're such a child
 
@Zoidberg FAP: Functional, Applicative Programming?
 
Ell
@LightnessRacesinOrbit who? o.O
 
user142019
7:33 PM
@FredOverflow Tony Programming.
 
@FredOverflow oh, snooze
 
@Ell guess
snooze?
 
Ell
Meh I'm too tired
 
@FredOverflow not true
you cannot do typename foo x;
typename can only appear before qualified names
ah yes, only for nested names
lol
 
Hey, you're even less up to date than I am :-)
 
7:35 PM
lulz
 
Ell
this is such a good idea! kickstarter.com/projects/mycestro/… a mouse that you don't need to move your hand for!
 
Xeo
@Johannes: Interesting. Did you ever have to use that candidate_set thing for anything?
 
@Xeo no it was just for fun :)
@Xeo i made it after playing with surrogate call functions
 
Xeo
@DeadMG: Pfft, comes into the room, spouts some childish non-sense, and leaves on the mark. Btw, do you plan to support functional programming in Wide?
 
because they are the only way to have perfect forwarding in C++03
 
7:38 PM
@Cicada ping.
 
@Xeo Sure.
 
Xeo
@JohannesSchaub-litb Now that you mention it, you're right.
 
i.e like void ff(int) { } void gg(bool) { } struct A { typedef void f(int); typedef void g(bool); operator f*() { return ff; } operator g*() { return gg; };
i think i played with that first, and then thought i would do something fun
@Xeo i asked the geordi maintainer for whether he perhaps wanted to use it
but he said that it shows them totally ordered, instead of showing the actual partial order
so he rejected it :)
 
Xeo
lol
 
lol ^ the commentary is hilarious
 
7:41 PM
@Bartek back
 
@Cicada how long can one eat? log in.
I've beaten a thousands bots waiting for you
 
Dinner with family is sacred
 
I hope your anus is ready
2
 
uh.
wish me luck guys.
I am gonna need it
 
7:43 PM
@BartekBanachewicz you've beaten off a thousand robots?
good luck for whatever it is that you need luck for
 
@Cicada wut
 
@LightnessRacesinOrbit fighting Cicada
 
@sehe It appears she is good at SC2.
 
wokay
 
7:45 PM
i'll random
just to ashame him
 
@JohannesSchaub-litb perhaps you have time to check over the answers here?
33
Q: Set all bytes of int to (unsigned char)0, guaranteed to represent zero?

refp This is not a matter of recommended practise (nor undefined behavior), but about what the c++-standard actually guarantees in the matter of turning all bytes of an integer type to the value of (unsigned char)0. The Question(s) In the snippet below, is the expression used by the if-stateme...

The puppy's is particularly short :)
3
 
Oh, the bounty expires in 6 hours
 
Xeo
@sehe Leave the ^ out!
 
haha
 
Xeo
7:47 PM
Also, isn't it "puppy" not "puppie"?
 
in C99, all-bits-zero is guaranteed to be a representation of zero
 
@Xeo All set
 
Xeo
Gotta love OOC stars.
 
@JohannesSchaub-litb Whoa. Could you write that up in an answer? Preferrably with some tangible reference?
 
for \0, i seem to remember it is all-bits-zero
and it has value of 0
 
but that's only a char :(
 
@sehe The question clearly states it.
 
@JohannesSchaub-litb Isn't '\0' int? I guess we're back to C++.
 
@DeadMG Mmm. I'd have to re-read this. I must admit I read this stuff looooooong ago. Around when it was created.
 
@sehe and I believe for unsigned, it is guaranteed that zero is all zero bits
 
7:50 PM
I remember the discussion raging for a while in chat. Then refp posted the answer, and when he complained recently that it still lacked a conclusive answer I thought I'd throw in a bounty.
Sadly, I'm not sure I'm qualified to award the bounty... [sic]
 
can't imagine how it should otherwise be, since they have no nonvalue bits
 
@JohannesSchaub-litb Well, if they have an inverted representation? I.e. 1111111111111111 equals zero?
 
@Collin lol
 
Assuming a system where set bits mean zero, and cleared bits mean one.
 
Xeo
7:51 PM
Reversed two's complement?
 
@Xeo unsigned, but yeah
 
@sehe not possible because of the definition of "~"
 
Xeo
Oh wait, unsigned.
 
@JohannesSchaub-litb Oooh. Now we're getting somewhere. What does the spec say for ~?
 
The spec for ~ is flawed.
It's called "ones' complement" not "one's complement".
 
7:54 PM
@Griwes This is the bullshit you get when you try to make it so function calls don't need parens because you think you're so damn cute
 
@R.MartinhoFernandes lol. You can write that up for highest voted comment, I guess
 
@sehe hmm perhaps it was the C spec..
so i misremembered
 
Anyway, inverting the bits works fine if you use a inverted bits system.
 
@Collin No, it could be made sane if && and and were exactly same thing. Which is the only sane choice in this case.
 
@sehe not sure though whether a "pure binary numeration system" would forbid that
 
7:55 PM
@Collin "Exactly" as in "substitute and with && before compilation".
 
Actually, the system with all inverted bits does not change anything, unless unsigned char uses a different system.
 
Xeo
Yeah, just wanted to say that
 
Maybe "first two bytes use inverted bits" then.
 
C99 says "If the promoted type is an unsigned type, the expression ~E is equivalent to the maximum value representable in that type minus E."
 
Xeo
@R.MartinhoFernandes I don't think that would work?
 
7:58 PM
Why not?
 
Xeo
hm.. operator| would do strange stuff for uint64 and uint32... no, wait, promotions.
 
I am assuming the bitwise operators operate on the values, not on the underlying representations, i.e., why assume a broken operator|?
 
doesn't C say that the positive range of signed integral value types must use the representation that the corresponding unsigned type uses?
together with the requirement of C that the implementation must use either one of signed magnitude, one or twos complement, C would forbid an inverted binary numeral system
 

« first day (862 days earlier)      last day (4071 days later) »