« first day (492 days earlier)      last day (4442 days later) » 

1:01 PM
0
A: Why structure can not contain Instance of itself?

FredOverflowstruct bedroom { bed b; table t; bedroom r; }; Do you see the problem now? A bedroom would need storage for an infinite amount of beds and tables.

 
oh no
0
Q: What do you recommend for project management software?

brazil farnandisI'm looking for a project management program that can do it all: manage documents, contacts, to-do lists, estimates, and track hours. Clients have me on Google docs and BaseCamp, but I'm looking for the best for my own business. Suggestions?

 
1:18 PM
@FredOverflow he he, good answer. +1
 
What about very small values of infinity?
 
@AlfPSteinbach I think in this case, real world examples are better than foos and bars.
@daknøk still way too large for modern computers
 
"small values of infinity" say whut?
 
math joke
 
Like "π = 4, but only for very large values of π."
The joke becomes reality sometimes on computers when very large integers are involved.
 
1:24 PM
how?
 
integer overflow
 
What does that have to do with infinity?
 
nothing
Does this evil C++ tutorial mention references?
It does mention pointers, but I cannot find anything about references.
Did the writers go crazy?
 
@daknøk Doesn't matter, you don't want to learn C++ from Internet tutorials.
 
did I mention I absolutely hate cplusplus.com ?
 
1:30 PM
Me too.
 
896
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are released every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...

 
When I was a newbie, it misguided me for over 6 months.
 
me too :P
 
@daknøk Learning C++ from Internet tutorials is next to impossible. You will most likely learn a crippled version of C++ known as "C with classes".
 
I have a copy of The C++ Programming Language and the C++11 standard.
 
1:31 PM
Then I bought some good books on C++, and found everything was different.
 
@daknøk Neither of those will help you learn modern C++. You need to read a proper introduction to C++.
I suggest "Accelerated C++" or "C++ Primer".
 
I'll take a look at C++ Primer.
 
If you have no prior programming experience, "Programming: Principles and Practice using C++" would be the first choice.
 
I do :P
 
Then that particular book would probably be overkill.
 
1:34 PM
I've found a copy of C++ Primer 3th edition.
 
What do you mean, "fixed"?
 
lol, this answer is helpful.
 
Anyway, 3rd is very outdated, 4th is from 2005.
@IntermediateHacker How can the STL not be mature for C++? :)
 
> (Yeah downvote me, you neophytes.)
 
I see the word "neophytes" as offensive. Flagged. (:
 
1:38 PM
hey, I just quoted it from the answer. don't hurt the messenger.
 
I flagged the answer, not you.
 
What's a "neophyte"?
 
no idea.
 
neophyte |ˈnēəˌfīt|
noun
a person who is new to a subject, skill, or belief: four-day cooking classes are offered to neophytes and experts.
• a new convert to a religion.
• a novice in a religious order, or a newly ordained priest.
ORIGIN late Middle English: via ecclesiastical Latin from Greek neophutos, literally ‘newly planted’ but first used in the sense ‘new convert’ by St. Paul (1 Tim. 3:6), from neos ‘new’ + phuton ‘plant.’
Oxford Dictionary
 
Ah, so neophyte = noob?
 
1:39 PM
lol.
 
lol @ the edit
 
My mind slipped :)
 
(:
Is the latest edition of Accelerated C++ from 2000?
 
Probably, hasn't been updated in a long time.
 
Going to get a copy ASAP. (:
Next year I'll be forced to write Java. ):
 
1:58 PM
Be sure to get a copy of "Effective Java" (2nd Edition) by then.
 
"functions must include at least one return statement and are not permitted to fall off the end of the function." isn't that false?
 
If by "function" one means "a C++ function with a return type other than void", that statement is correct.
void C++ functions are often called "procedures" instead.
And the Haskell guys only say function if it's referentially transparent.
 
Then why does int foo() {} compile with clang++ foo.cc -pedantic and g++ foo.cc -pedantic?
 
How about -Wall -pedantic?
 
The standard says "Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function."
 
2:06 PM
What book? Is it even a C++ book?
 
Accelerated C++
 
@daknøk use -Wreturn-type (should be enabled by -Wall)
 
@KillianDS Strangely enough, -Wall doesn't include all warnings :)
 
@daknøk Well, if the standard says that X causes undefined behavior, one could argue that X is not permitted. That doesn't mean a diagnostic is required by all compilers.
 
2:13 PM
@FredOverflow I know but I'm quite sure this one is in it :p
 
The standard doesn't forbid it, so it's permitted.
 
In the same sense that the standard doesn't forbid i++ + ++i.
 
@daknøk The standard doesn't forbid use of "delete" for data allocated with "new[]" too, but you go ahead and use it :p
 
Anyway, I think it's good that a book says a function returning non-void should actually return something, no matter how it's phrased.
 
If I were to write a C++ compiler, everything that would cause undefined behavior that's known at compile-time would have the compiler delete a random file. Of course I wouldn't mention it in the documentation.
That'll teach them!
 
2:24 PM
If I were to design a language, I'd eliminate undefined behavior as much as possible.
 
@FredOverflow "as much as possible" is silly. Either make it a safe language or don't.
 
If I were to design an esoteric language it would be this one: "The language has four operators: ., :, ; and ,. When the compiler encounters either of these characters, the behavior is implementation defined. When the compiler encounters any other character, the behavior is undefined."
 
@Pubby It's pretty hard to get rid of undefined behavior if your language supports concurrency.
 
@FredOverflow Well depends on the design I guess
 
As soon as your language has threads (and which systems language doesn't have threads?) some things are bound to be undefined.
 
2:29 PM
@FredOverflow restricting shared memory to only locked variables (lack of better name) should help a lot
 
@FredOverflow Just thinking out loud, but perhaps it's possible if all (non-local) variables are thread-local by default. And to make them shared you'd need to use std::shared<T> in order to enforce locking.
Nevertheless, users tend to always find ways to invoke UB.
@daknøk You changed your mind? :)
 
it said "not defined" d:
I like undefined behavior, except when I must debug my own code myself.
 
Replacing UB with termination would require the runtime to do a lot of checking which would result in much overhead. (Essentially this would require your application to behave like Valgrind, which is known for causing huge slowdowns.)
 
The thing that really sucks is implementation defined behavior.
(I'm a portability-freak.)
@StackedCrooked but you don't have UB. (:
 
@daknøk You should never go into networking then :p, almost every vendor has it's implementation some discrepancy towards the "standard protocols"
 
2:38 PM
@daknøk Always run your application with Valgrind to get rid of UB :D
 
@StackedCrooked will valgrind catch i++ + ++i?
 
@KillianDS a decent compiler will warn.
 
@KillianDS Dunno. I was just joking :)
 
@KillianDS Never done anything with networking except for downloading a file over HTTP and implementing an MSN client. d:
MSN is one of the worst network protocols I've ever seen. ><
No decent documentation, mix of HTTP, SSL and MSN protocol, slow as hell, cookie mess…
 
@KillianDS Even gnu complains about i++ + ++i.
ideone uses gnu, right?
 
2:49 PM
Ideone used GCC, yes.
 
> warning: operation on ‘i’ may be undefined
 
@FredOverflow I was talking about valgrind catching it, not a compiler (last time I checked valgrind isn't a compiler)
 
If a compiler already catches it, who cares about valgrind?
 
People who use a compiler that sucks.
 
it was a theoretical discussion ...
 
2:52 PM
@KillianDS No. Valgrind doesn't look at the source. It will only catch if the undefined behaviour leads to actual illegal memory references (out of bounds, use of uninitialized memory)
 
Clang can do static analysis on source code, but the C++ part is very immature.
It's very good at Objective-C, though.
 
@KillianDS: for all intents and purposes, Valgrind will not 'catch' this. Unless you are running iterators into the unknown.
@daknøk I'm not even sure static analysis applies to cases like these; in this case there is only one undefined step: the step that translates source code into object code. LLVM's static analysis operates on the object code, and it can only assume that the object code accurately describes the programmer's intent.
 
brb
 
In short, it is the job of a well-behaved compiler to notify of easily detected, documented cases of undefined behaviour.
 
Mmm, this is what static analysis tells me:
 
2:57 PM
@daknøk I guess that static analysis could help in a few cases, e.g. where the ordering of emitted bytecode operations makes it so, that some of the instructions have no effect after the later instructions are executed (which is very possible with things like i = i++ + ++i. But that would be coincidence and depend on what the compiler generated, which ironically is the thing that is undefined
@daknøk That doesn't warn of UB.
 
Nope (:
Neither does compiling it do.
Clang sucks.
 
@daknøk Make it so, that the initial value of i is read from the console, and the 'warning' disappears. It is merely a 'possible optimization'/'possible programming mistake' kind of warning.
@daknøk Nope.
 
@sehe no warnings, the analyzer doesn't tell anything either.
 
@daknøk Yeah that's what I meant; I meant the message you showed would go away
 
ah oké
mmm
Since when is NULL + 1 a null pointer? Am I missing something?
(That's C, by the way.)
 
3:10 PM
@daknøk It's probably a simplified error for "you're doing pointer arithmetic with a NULL pointer and try to dereference it, which is bad!". The issue stays actually the same
 
@daknøk it's class of bugs named "null pointer dereference"
 
ah
 
general optimization question. I have a relatively large char array (blitz++) dim 30x200 approx., which I'm passing around via const ref to a bunch of functions. I was wondering if it would speed things up to have the array as a data member of a class, and make all those functions member functions of the class.
Of course, one could just try and see, but I wondered if there are any general heuristics one can apply here.
 
Why would it be any faster or slower? It usually shouldn't matter in C++ (except for when the functions are virtual).
Anyway, profile and benchmark before making such assumptions.
 
@daknøk : Well, since one is passing the object around vs not.
 
3:22 PM
I never realized how hard it is to make esoteric languages :S
 
Class functions get a this pointer, which is needed to find the array. It might even be slower.
 
@daknøk : Hmm. Interesting. Thanks.
 
I forgot what I was about too google.
 
3:39 PM
Silence…
 
@daknøk it means that everyone is working, not appending lines to chat
while (idle) chat.append(make_random_shit());
 
hm, counting moderators, still 2 SO moderators, one SO employee, and one clc++m mod
 
4:13 PM
Woo, I'm back.
5
For real this time.
 
Programming is continuous fun. Every five minutes I recompile code, run regression tests, and see that I didn't broke code. It makes me happy.
 
Hey, welcome back!
 
@RMartinhoFernandes Welcome back!
@RMartinhoFernandes What happened? Just more ISP/modem trouble?
 
user784668
@Abyx It would be more fun if you did break code.
 
@Fanael no, there is no fun.
 
4:19 PM
@FredOverflow It's a bit different. For example, I very often use a function called throwX, defined as follows:
bool throwX( std::string const& s ) { throw std::runtime_error( s ); }
I wouldn't like the compiler to choke on that.
 
@AlfPSteinbach why bool ?
 
Robot!
 
@Abyx Like this:
    inline wstring shortPathFromExisting( wstring const& normalPath )
    {
        if( normalPath.length() == 0 ) { return L""; }

        int const bufferSize    = ::GetShortPathName( normalPath.c_str(), nullptr, 0 );
        hopefully( bufferSize > 0 )
            || throwX( "winapi::shortPathFromExisting: GetShortPathName failed (1st call)" );

        wstring shortPath( bufferSize, L'#' );
        int const nCharacters   = ::GetShortPathName(
            normalPath.c_str(),
            &shortPath[0],
 
@sehe I was spending some time back with my parents, and over there the 3G modem is was my source of the Internets. Since it died, I spent a fun week out there in the middle of nature. Last Thursday I just was visiting my uncle and took the opportunity to use his Internet access. Now, I'm back home where I have real Internets and none of that UMTS crap.
 
Oi, ideone.
 
4:21 PM
@daknøk I think the real explanation is a bit more dense than what has been mentioned. Pointer arithmetic is only defined within contiguous arrays. So saying int*p=NULL; *(p + 1) implies that p must point to/inside a valid allocated array, which cannot be true, since p is statically known to be NULL.
 
oh hai
 
Pointer arithmetic sucks.
 
@CatPlusPlus eggs
 
@sehe yes
 
@sehe Moo.
 
4:22 PM
@sehe thanks, I didn't know that!
 
@AlfPSteinbach looks sorta obscure. I prefer check_x(bool cond, string errorMsg);
 
Reading the standard is a very rewarding hobby
... Not :)
 
user784668
@AlfPSteinbach hopefully? What's that?
 
@Abyx That looks very obscure (non-idiomatic), and also inefficient because it will evaluate the string expression always
 
Finding specific things in the standard is a form of art.
 
4:24 PM
Presumably #define hopefully(x) (x)
 
@Fanael Nice looking (subjective) error/precondition checks.
 
@Fanael bool hopefully( bool const v ) { return v; }
 
Or that.
 
@Xeo Cool, I should build it again.
 
@AlfPSteinbach what's the point of that?
 
4:26 PM
Forces coercion to bool.
 
but you're passing it a bool already
 
just syntactic sugar :D
 
shouldn't you pass it an int and return bool
 
Doesn't matter, it will be coerced to bool.
 
user784668
ORLY, GCC? ORLY?
 
4:26 PM
hmmm
I see
 
@AlfPSteinbach It should support contextual conversions.
 
You won't be surprised with overloaded || etc.
Not that you should overload ||, like, ever.
 
Boost tribool does it.
 
user784668
This awesome compiler just started thinking that it'll be great if the default executable file name is a.out.
 
I'm off to home. Can code whole night so taking my rest...
 
4:28 PM
As is, auto x = get_some_shared_ptr(); hopefully(x) || stuff; won't work.
 
@Fanael just started is misqualification of the century there
 
@CatPlusPlus Very good point. I wonder if I thought of that? I can't remember.
 
a.out is a file format used in older versions of Unix-like computer operating systems for executables, object code, and, in later systems, shared libraries. The name stands for assembler output. a.out remains the default output file name for executables created by certain compilers/linkers when no output name is specified, even though these executables are no longer in the a.out format. Use An a.out format for the PDP-7, similar to the a.out format used on the PDP-11, appeared in the first edition of UNIX. It was superseded by the COFF format in AT&T Unix System V, which was in ...
 
user784668
@sehe It always used a.exe.
 
Oh, you're getting a.out on Windows?
 
user784668
4:29 PM
@RMartinhoFernandes Yeah.
 
I can see why a.exe is more desirable than a.out.
 
@Fanael Oh. You're on windows. Sucks to be you :)
 
@CatPlusPlus Because on Windows a.out won't be runnable.
 
(I'm on windows too, but I love my fullscreen terminals and vim; and I do C#...)
 
GCC should be guessing the default name like MSVC.
 
4:30 PM
@RMartinhoFernandes any problem with your batteries these days? :P
 
user784668
@sehe In fact, I'm currently trying to move away from Windows.
 
@sbi Yeah, pretty good. I love the opening paragraph.
 
And maybe someone would finally make MinGW normalise paths.
 
> The day war was declared, a rain of telephones fell clattering to the cobblestones from the skies above Novy Petrograd. Some of them had half melted in the heat of re-entry; others pinged and ticked, cooling rapidly in the postdawn chill. An inquisitive pigeon hopped close, head cocked to one side; it pecked at the shiny case of one such device, then fluttered away in alarm when it beeped. A tinny voice spoke: "Hello? Will you entertain us?"
 
user784668
Oh wait, it's not GCC. clang++ x.cpp does not look like GCC invocation to me.
 
4:30 PM
@Fanael you make it sound like a hard thing to do :)
 
@RMartinhoFernandes I want a box that makes things
 
@RMartinhoFernandes you never answered to my comment in your answer , can you please look?
 
Oh, I heard Clang support for Windows was shady.
@AlfPSteinbach It's called a cornucopia machine (you probably know that if you read it already).
 
Also, I'm doing a showcase: namespace on wiki.
So, if you people have any fun projects to show, there you go.
 
@MrAnubis Sorry, been offliine for a week. I'll check it out.
 
4:32 PM
The Festival had come to Rochard's World -- Singularity Sky @sbi see... you're instigating a cult
 
@RMartinhoFernandes Thanks :)
 
user784668
@sehe Oh, and it's a vboxed Windows.
 
@Fanael Those are most easily wiped
@Fanael in all fairness, also most easily kept, because if you don't allow it to run, windows generally won't bother you
 
I still haven't bootstrapped a new Windows install on this hard drive. Can't pirate without the Internets.
Can't say I missed it, though.
 
user784668
@sehe If you more or less know how to use it and what to expect from it, it won't bother you, too. As is the case with all OSes.
 
4:37 PM
Wait, cstdio or stdio.h? What's the 'better' one?
 
@MrAnubis I'm not sure what part you don't understand. Do you know what an "injected class name" is?
 
user784668
@Pubby fstream
 
@Pubby If it worked nicely, cstdio would be preferable.
But it doesn't. All compilers pollute the global namespace anyway.
 
I thought @AlfPSteinbach said use stdio.h though :S
 
@Pubby Because cstdio doesn't buy you what it should buy you: clean global namespace.
All it gives you is that you get the names in namespace std (but global too).
 
4:38 PM
Yeah. It's silly
 
It's the implementations' fault.
 
@Fanael Yes. But on prolonged use it will turn out more true for the one OS than for the other :)
 
namespace c_io {
  using namespace std;
  #include <cstdio>
}
 
Doesn't help.
In fact, it can turn bad.
13
Q: Is it a good idea to wrap an #include in a namespace block?

R. Martinho FernandesI have a C header that was written to compile as both C and C++ (it only uses features from the common subset, and uses that extern "C" thing). Problem is, that header declares stuff in the global namespace. I'd rather avoid that for the usual reasons. I thought about doing this: namespace foo ...

 
ah ok
Didn't think of name mangling.
 
Hey, I need access to the wiki, btw. Gimme a moment to see if I can remember my username...
 
Editing is free for all now. For joining as a member there's a password I already forgot.
Wait a sec.
Oh, wait, no, I screwed up and there actually is no password.
 
@sbi This is the message that made my school's filters flag up and block this :(
 
So that's why I couldn't find it in the panel.
"Cat Plus Plus is the greatest person in the world"
 
4:52 PM
Ping me when you join for moderator powers.
 
@CatPlusPlus Ready.
 
How do you join?
nvm
 
The Robot, right?
 
@CatPlusPlus yay, I finally get to join
 
@CatPlusPlus Yep.
 
4:54 PM
There you go.
 
"Joining the site requires a Wikidot account…" but I have one.
 
@daknøk You're already a member.
 
@RMartinhoFernandes You didn't know this? I'm surprised, I finally know something someone else didn't....
 
@CatPlusPlus ah d:
 
@CatPlusPlus Ping, I joined.
 
4:58 PM
@Xaade You're not a room owner.
 
I gathered enough frequency credit that I can go out for a whole week without being unfrequented.
 

« first day (492 days earlier)      last day (4442 days later) »