« first day (461 days earlier)      last day (4486 days later) » 

12:00 AM
The worst thing is that that warning is actually useful, when given out properly, so you can't just -Wno-XXX on it.
 
@RMartinhoFernandes right, but GCC diagnostic has a push/pop to change the type for just a few lines already
 
@MooingDuck #pragma GCC diagnostic ignored "-Wxxx"
 
@CatPlusPlus :/ really? I didn't see documentation for that. bah. I'll try it some other time when I have those files open again
 
It's right there in what you linked.
 
12:03 AM
@MooingDuck There's an example in the page you linked.
 
@RMartinhoFernandes facepalm. I.... need to get off the computer
 
Well, I'm going to sleep.
Good night.
@Xeo here's a question you might like: stackoverflow.com/q/8935055/46642
 
12:44 AM
Hi, did you meet with situation that one function from static lib did work, and other was throwing errors during runtime? I'm talking about connector c++ lib- result->getInt does work, but result->getString throws 'access violation'
but only when I want to assign value to variable
when I just call result->getString it doesn't complain
 
Oh gawd, I think I actually finally got how sequent calculus works.
Two weeks too late, as usual.
 
you lie
 
False.
 
this statement is false!
 
12:58 AM
@CatPlusPlus haven't heard of sequent calculus - what is it used for?
 
Proofs.
Also known as Gentzen method or LK system.
 
to validate consistency?
 
In proof theory and mathematical logic, sequent calculus is a family of formal systems sharing a certain style of inference and certain formal properties. The first sequent calculi, systems LK and LJ, were introduced by Gerhard Gentzen in 1934 as a tool for studying natural deduction in first-order logic (in classical and intuitionistic versions, respectively). Gentzen's so-called "Main Theorem" (Hauptsatz) about LK and LJ was the cut-elimination theorem, a result with far-reaching meta-theoretic consequences, including consistency. Gentzen further demonstrated the power and flexibility ...
 
I really don't understand some of Bjarne's exercises in his book TCPL: e.g. "What, on your system, are the restrictions on the pointer types char *, int *, and void*?
For example, may an int* have an odd value? Hint: alignment"
 
Some CPUs have strict alignment requirements.
 
1:02 AM
What's that?
 
(as an optimization/simplification of addressing)
 
x86 will let you get away with unaligned access most of the time.
 
So padding bits
 
Though SSE is strict AFAIR.
 
SSE?
 
1:03 AM
Data structure alignment is the way data is arranged and accessed in computer memory. It consists of two separate but related issues: data alignment and data structure padding. When a modern computer reads from or writes to a memory address, it will do this in word sized chunks (e.g. 4 byte chunks on a 32-bit system). Data alignment means putting the data at a memory offset equal to some multiple of the word size, which increases the system's performance due to the way the CPU handles memory. To align the data, it may be necessary to insert some meaningless bytes between the end of the la...
 
@CatPlusPlus thanks
 
@CatPlusPlus I always wondered how much the compiler will take care of that for you, automagically (esp in case of gcc)
 
Apparently in Java it reads a boolean as a bit
I thought that was impossible for hardwares
 
C++ has some alignment guarantees, but you'd have to ask someone else.
 
new is guaranteed to be suitably aligned for the type it operates on
in addition, new char[] is guaranteed to return memory suitably aligned for any type
 
1:06 AM
@LewsTherin You read a byte and then extract bits.
 
@DeadMG ty - good to know
 
@CatPlusPlus Oh. That makes more sense.
 
Though compressing booleans into bitmaps is a rather aggressive space optimisation with some performance implications, and I doubt JVM does that to every bool.
 
@DeadMG does the new guarantee apply to structs in general or just primitive types?
 
what?
you can't possibly have new T; return a T that isn't suitably aligned
 
1:08 AM
so, lemme flip it around the other way - when do I need to worry about alignment?
 
Always, if you care about performance.
And portability to platforms with stricter alignment requirements.
 
I mean, in what cases do I need to worry about alignment?
 
when dealing with types that have unusually large alignment concerns
for example, SSE types
 
ic - that's what I wanted to know - ty
 
and if implementing your own containers
but in the general case as a user, you don't need to worry about alignment
 
1:11 AM
nice compiler 8^)
 
Is there a way to see the code generated by MSVC?
 
can someone help me with c#?? i know this is c++
no one is in the c# lounge >.<
 
@Psycho Know the feeling :(
Look at the tagline though :)
 
tagline?
 
Or whatever it is called - room description
Ask the question..
 
1:22 AM
@LewsTherin /Fa
 
@CatPlusPlus ?
 
@CatPlusPlus Merci
 
1:37 AM
What the fracking hell is anachronism used qualifiers on reference are ignored?
 
What?
 
"anachronism used : qualifiers on reference are ignored"?
Msvc warning
 
Code.
 
Too much consts in those references.
 
1:48 AM
?
 
You can't rebind a reference, so & const is meaningless.
It should be just const std::string&.
 
But I am saying a const reference to a const string
 
References are not pointers. All references are const.
You cannot rebind a reference.
 
Oh yeah
So it is redundant
 
And most likely ill-formed anyway.
 
1:50 AM
can someone help me with c#?
via teamviewer
 
@CatPlusPlus ill formed?
 
Illegal.
 
Ah, right. Thanks!
@Psycho Can't you just ask here?
 
whys my name blue
 
1:54 AM
Your monitor is dying.
 
lol
 
Is there a way to start a private chat with somebody?
instead of replying to comments, I thought I'd invite the SOer to a private chat for a discussion
 
There's no such thing as private chat. All rooms can be viewed by everyone.
You can just create a room and give them the link.
 
ok, maybe not private, but separate... so that it
ah
great
 
omfg, asm code is massive
Does .substr check string bounds?
 
2:16 AM
Network Solutions won't support Django. Looks like I'm stuck with PHP. :(
 
Crappy shared hosts are not worth paying for.
 
It's all I can afford.
 
most hardware these days are powerful enough that you can stuff your own server inside virtualbox - as long as you can get a static IP to serve to the world, you're all set...
 
Man, DreamHost is looking better and better.
 
2:59 AM
looks like the SOPA wave has begun: usatoday.com/tech/news/story/2012-01-19/…
 
SOPA hasn't passed yet.
MegaUpload fight is going on for a while now.
Well, was.
 
I meant SOPA-in-the-abstract... ...there are enough laws on the books for the feds to act - the surprising thing about this news is the global reach of the feds
this is a nice site: projects.propublica.org/sopa
 
3:58 AM
Can someone please help me -> stackoverflow.com/questions/8936559/… Thanks in advance.
 
 
2 hours later…
sbi
5:49 AM
Rah - 100th gold badge! :) #stackoverflow Unfortunately I think the next big milestone is 1M rep - in about 5 years...
 
6:16 AM
Quick questions guys, if there any of you?
 
sbi
Nobody here. :)
 
hehe... 1 question please
 
sbi
"No questions about asking questions. Violators will be shot. Survivors will be enlightened properly."
 
What do you mean when you say "Construction of an object"
:)
What is sequence of things which are done when we have something like Base b = new Base;
in main
 
sbi
@Leoheart An object is an instance of a type. In order to use an object, there must be one. Objects are created from raw memory by executing a constructor that sets up the type's invariants. This is called construction.
 
6:19 AM
type invariants? Could there be a simpler set of words so that i can understand better please.
and i know that definition. I want to understand the sequence f things which are done after
Base b = new Base;
 
sbi
@Leoheart This won't compile, because new T returns a T*, which you cannot assign to a T. (Are you sure you are in the right room? This is not the Java room, nor the C# one.)
 
sorry.. I meant Base* b = new Base;
 
sbi
@Leoheart Invariants are things that must always hold true for a type. For example, for an empty string, std::string::size() will always return 0.
 
i am coding a lot these days 1/2day c++ at home for fun and 1/2 day at job in Java, which sometimes causes this mistake + my incomplete knowledge
Okay.
Got it.
Now, could you elaborate on the process or sequence of steps.
For example i would say something like
default constructor is called of class Base and which then ......
 
sbi
@Leoheart The right side of the assignment is called a "new expression". It does two things. First, a chunk of memory big enough to house an object of type Base is allocated by calling the appropriate operator new. Then the constructor of Base is invoked at that address, creating a Base object. The address is then returned by the new expression and subsequently assigned to b.
 
6:24 AM
got it...
Awesome.
so this statement
Base* b = new Base();.... can this statement be said "Constructing an object"
 
sbi
Note that this two-step approach to object creation (1. memory allocation, 2. constructor call) is true even for objects created on the stack: Base b;. First, the memory is allocated on the stack, then the constructor is called at the address. After constructor finishes, there is an object where before was only raw memory.
 
or is it allocating a memory but in between as constructor is called, so construcing is just a portion of work.
Yeah. I understand that ...
You have made things so clear in my mind
 
sbi
@Leoheart It is doing both. :)
Often, this is colloquially referred to as "creating an object on the heap."
 
Yup.
Totally Understood
Awesome my friend. (if thats fine to say)
I have one more question, which i have never understood completely in my 5 years of young development experience
 
sbi
When an object is destroyed (automatically for objects on the stack, manually — by invoking delete — for objects on the heap), the sequence is the opposite: First, the destructor is called, and then the memory is deallocated.
@Leoheart Shoot.
 
6:28 AM
Yes, totally makes sense.
Question is
gimme 1 min. please
So yes.
How are Virtual table entries filled ? I know its compiler dependent, but please support your answer with a common way to do it.
 
sbi
@Leoheart First off: There's nothing in the standard requiring compilers to use virtual tables. If they can do with dead kittens instead, then that's fine with the C++ standard.
 
I know that too as i didnt see anything in sir Bjarne Stroustroup standard's book.
but i know its implemented by every compiler, so could you please help me understand any of those implementations
 
sbi
Virtual tables are set up for an object before the constructor is called. They are set to the type for which the constructor is about to get called.
That is, in an inheritance scenario, where constructors are called from base to derived classes, in any constructor executed, you can never call a virtual function and arrive in on overload belonging to a type that's derived from the one the constructor is called.
(That's quite a mouthful. You might need some time to digest that. But it's important.)
 
@sbi The pointer is set up. The table is shared.
 
sbi
@LucDanton Yes, I was imprecise there. Virtual tables are one for a type, pointers to virtual tables are one for an object.
 
6:35 AM
I am reading.
Virtual tables are one for a type ... just to add, only when we have virtual functions declared in a class.
 
sbi
@Leoheart Yes, I was imprecise there. Sigh.
 
No worries sir.
 
sbi
[afk for a few mins]
 
Now
striaght back to my question, implementation of it and how are the entries filled. what are the key value pair.. assuming its a map. Or it could even be an array.
or any damn data structure. What i want to understand is how are these entries filled, with what values, what do we consider here for efficiency..
 
Aw, it's so sweet to be able to use -std=c++11 with GCC now.
 
6:41 AM
what is [afk]..
 
sbi
@Leoheart absent from keyboard :)
@Leoheart It's (usually) an array of function pointers.
 
Ohh okay
Yes. True
where i am assuming that index of an array is decided by the order of virual functions in that class.
 
sbi
@Leoheart It's implementation-dependent, of course, but, yes, that's how compilers are usually implementing it.
 
Got it. So now lets come to the most important (for me to understand)
Lets take an example of Inherited classes and then fill out the VT, shall we?
 
Order can be arbitrary because to call a member, a class definition has to be available. The index to lookup can be determined by following the same arbitrary rules that were used to establish the table in the first place.
So you can order according to alphabetical order of member names, or lexicographical order of the token string, or whatever.
 
6:52 AM
makes sense...and as mentioned earlier it is compiler dependent, so it is very likely to see 100 or more varied implementations
I so suck at coding :(
can anyone please have a look here codepad.org/D4WSyUFQ
is anyone here?
 
Missing semicolon at the end of the class definition.
class foo {};, not class foo {}
 
yaa..
i just solved that
sorry
 
Did you solve that right after asking?
 
yaa
2 or 3 minutes after asking
 
Rubber duck debugging, Rubber Ducking, or the Rubber Duckie Test is an informal term used in software engineering to refer to a method of debugging code. The name is a reference to an apocryphal story in which an unnamed expert programmer would keep a rubber duck by his desk at all times, and debug his code by forcing himself to explain it, line-by-line, to the duck. The process is to meticulously explain code to an inanimate object, such as a rubber duck. It is expected that when the programmer comes across a piece of code that is incorrect, they will realize this. Other debugging usa...
This happens a lot in here :)
 
7:07 AM
What happens a lot?
 
Rubber ducking.
 
Oh okay.
i need help
and this time, i think its something which i don;t understand
Why am i seeing the error here?
It shouldn't call any default constructor right?because i am using initialization list
 
The second colon should be a comma.
foo(): bar(baz), quux() { is how a member initialization list looks like.
 
you wont believe though
but that is what i exactly did maybe like 10 ms before what you wrote
sorry, i know it looks like i am lieng , but thats true
 
7:16 AM
At least you know ctor init lists exist. You're way ahead of majority of SO users.
 
This morning I thought I found a use for std::mem_fn, but now I'm not sure I do.
 
Only two upvotes for cute ASCII art? I'm disappoint.
 
hmm.:(
 
Also, I PASSED LOGIC.
FINALLY.
LOUD NOISES AND POSITIVE THOUGHTS.
 
sbi
So now the @Cat is passed all logic.
Clap. Clap.
 
7:20 AM
:)
 
@Mysticial XS is down!
 
@bamboon Yeah, I noticed... they're off by a day. lol
 
So here i am ready with the program
 
are you sure about the one day?
 
Can any one help me in understand the VT implementation now codepad.org/geE5ApD7
 
7:23 AM
the "we are doing it right" makes me wonder
 
@bamboon IIRC, it was up yesterday.
 
@LucDanton and @sbi
there?
 
sbi
Of course we're there. The question is whether we're here, though.
 
hehe ya Okay
so ya, did you have a look at the program.
Please forgive me for messy code there, I didnt care much to do it the right way.
 
That barely uses any virtualness.
 
7:27 AM
i know..
Barely is enought because simple it is, better it is for me to understand
i have thrown this same question here many times.... but today i hope that with sbi, i can finally close the doubt.
i want to understand how the compiler fills the VT for the three objects
 
sbi
@Leoheart What is unclear about this?
 
VT entries
 
Why do you even care about vtable? It's an irrelevant implementation detail.
 
Because once an interviewer embarassed me in front of a team and i dont want to be embarassed again plus, ever good program should know most of the stuff which he may deal in.
Cat Plus, you program just asked me to commit suicide.
you program is way much neater than mine.
 
Language semantics are important, not silly implementation details.
 
7:31 AM
but i was rejected of a job which was offering more than 100k :(
 
You can tell that person to sod off the next time they ask a stupid question.
 
i won't because it's still not that of a stupid question.
i know its irrelevant to 99% of the stuff we do day to day but stil
So please help now :|
 
You may learn more from writing your own dynamic dispatch implementation in a language that doesn't support it (say, like C) than trying to reverse-engineer a preexisting one. YMMV.
 
sbi
@Leoheart Nah. He uses 8 spaces for a tab. That's not neat, that's an abomination! :)
 
7:33 AM
Actually, I used tab and ideone inserts 8 spaces.
 
haha.. well said sbi.
but please help me understand this :(
 
sbi
@CatPlusPlus Now trying to wiggle out of this embarrassing situation, are we?
Constructors are called base first, derived later, so that base class sub-objects are constructed when derived constructors are executed. Before base::base is called, the virtual table pointer is initialized to the virtual table for base. After the constructor has executed, it's initialized to the virtual table for derived, and then derived::derived is called. Then it's set to derivedderived, and derivedderived::derivedderived is called.
@Leoheart What's unclear about that?
 
> sorry, unimplemented: mangling overload
 
"After the constructor has executed.."you mean which constructor? Base class's
 
sbi
@Leoheart Yep.
 
7:39 AM
so are you assuming that there is only one VT
isnt it for each class?
got it that you are saying there about multiple VTs
but i dont undersand still.
 
sbi
"...the virtual table pointer is initialized to the virtual table for base." "...it's initialized to the virtual table for derived..."...it's set to derivedderived..."
 
ya.. i got it, as i wrote above, but i still dont understand
for example
In VT of base, we will have only 1 entry foo() lets say VT[0] is entry for foo.
What will be the value here VT[0]?
&Base::foo()
?
and for VT_Derived[0] = &Derived::foo()
 
Don't confuse the tables with the pointers to tables.
 
But tell me here if i am rwring.
Thats well said.
a->foo(); will be called by something vPtrBase->vtBase[0]
 
The VT entries for Base will point to the Base implementations while the VT entries for the derived classes will point to their respective derived implementations.
 
7:49 AM
yes..
 
That should tell you what the value of VT[0] is.
 
which is Base::foo()
isnt that's how run time dispatch done using VT
?
 
Dispatch is done through the VT pointer, such that you find the virtual table corresponding to the dynamic type as opposed to the static type.
 
vPtrBase is the virtual table ptr for Base
 
No such thing. The pointer is per object, not per class.
 
7:54 AM
ohh ya i meant object for class Base, thank you for correcting
I will go to sleep now. I understood some of it.
I will read more and come back with more questions.
 
ideone.com/PZOyJ Somewhat crude, but hey.
 
Good night, @LucDanton ,@CatPlusPlus, @sbi
ohh wait.. lemme read this one.
reading your program.
Is base_foo even part of any object?
 
No. Member functions are usually just normal functions that take object as first or hidden argument.
 
i understood the program but now understand the virtual dispacthing part
Can i ask a stupid question. How many times did you compile this to get the final result?
 
Twice. I got parentheses wrong on the casts to base pointer the first time.
 
8:07 AM
and if i may ask, since how many years are you working in c++?
 
Xeo
Oh, I wake up and you're manually implementing vtables here? How comes?
 
Sillyness ensued.
@Leoheart Don't remember.
5, 6, maybe.
 
hmm...
 
I learnt most during last 2, anyway.
Maybe less.
Who cares.
 
i hope i get a job using c++ and C so that i get more time in focusing on it and learning it more.
 
8:10 AM
It's either C++ or C.
 
Good.
Are we guys allowed to talk personal stuff here, like what you do and all?
 
Jan 16 at 4:27, by Cat Plus Plus
If you are new here, please read the newbie hints. Thank you.
The newbie hints explain that pretty much anything goes.
 
means yes :)
@CatPlusPlus Going to sleep, i will come back with the question later
 
Wonderful.
 
What?
back**
 
8:18 AM
I'm going back to probability crap.
 
P(Cat failing the probability exam) = 1 ?
 
Xeo
Oh, hi Robot. Thanks for the question, it's indeed interesting :)
 
> sorry, unimplemented: use of 'type_pack_expansion' in template
 
It's like fishing for bugs.
 
8:26 AM
@Potatoswatter you slept in a public building, you monster! :P
 
That is not really a bug.
It's just unimplemented.
 
It's bug not yet implemented.
It's a futurbug!
 
Yeah, I'm not exactly sure that error message belongs here actually. No idea what GCC is complaining about.
 
8:49 AM
Oh, std::mem_fn doesn't work with std::reference_wrapper?
 
Fallback to bind?
 
I'm avoiding it on purpose since arity has to be taken into account at the call site.
 
Xeo
What'cha workin on, @Luc?
 
I thought I had a need for std::mem_fn, but it turns out I need mem_fn-like functionality while still packaging an object with it. So like bind, except I don't want to use placeholders.
And in turn I need that to implement a smart operator which would be super neat with my own lazy-eval DSL.
Oh, I can use a utility that detects arity from pointer to members and then fill in a call to bind with appropriate placeholders.
 
@Xeo something tells me, you'r a little bit bored :P
 
8:59 AM
Any reason a hack like #define alignas(N) __attribute__(__aligned__(N)) would burst out of my chest and kill me in the process?
 
it's a define
sooner or later, you are going to regret it
 
Sooner than later I'm going to ditch it (when GCC finally implements it).
 
For an arity_of type trait, what should be the value for R (C::*)(A)? And for R C::*?
 
Oh, dammit, max_align_t is not supported.
@LucDanton 2 and something?
 
Heh, I'm going with 1 and 0.
I guess that and 2 and 1 are the two consistent answers.
 
9:11 AM
In Tesco this morning: Two young boys arguing, one cries to his mum. She shouts, "WELL MAYBE HE SAID THAT BECAUSE YOU *ARE* A COCK MONKEY"
not sure if good parenting or bad parenting
 
Well fuck, the type of placeholders is unspecified.
 
decltype(_1)?
There's also a std::is_placeholder.
 
I need to do something of the kind make_placeholder<Indices>()....
 
Hmm, some work, but seems doable.
 
Yeah, definitively. At the worst using specializations.
I'm just kind of miffed I can't do it out of the box.
 
9:17 AM
template <int N> struct placeholder; with a specialization for each.
 
boost::placeholder<Indices> {}... or whatever would work for instance.
Also, I forgot my forward_bind isn't really bind-like. D'oh.
> Internal compiler error: Error reporting routines re-entered.
Suddenly, out of nowhere!
 
I get these randomly ever since my last snapshot. I thought GCC couldn't handle specific TUs, but after reenabling them it can compile them. Sometimes.
For even more WTF the TU that just failed hasn't been modified for a long time.
Yep, apparently adding that arity_of trait to my type traits broke the TU.
 
So, the TU did change (through an #included header), just not its main file.
 
It did not change a binary/code generation sense though, since that type trait is (should be?) completely unused. Since it's all new.
And of course other TUs that use my type traits (which is almost but not quite all of them) don't complain.
When this happens I forlornly (and compulsively) check that there is not a newer snapshot available.
 
9:34 AM
But there are older ones!
 
Not bleeding edge enough.
 
Well, at least you have the bleeding you asked for.
:P
 
That I have.
I'm just a bit forlorn since I thought packaging a pointer-to-member + an object would be easy. I really want to move on to the interesting stuff (the DSL).
Welp, I'm just going to manually unpack whatever is convertible to a reference, so that'll pick up std::reference_wrapper.
Egad, now I have to inspect the class type.
 
9:54 AM
Hey my little nerds ;)
 

« first day (461 days earlier)      last day (4486 days later) »