« first day (377 days earlier)      last day (4578 days later) » 

3:00 PM
Why is it, with 'new' you have to specify what type you want to create
 
@LewsTherin No, UDP does not rearrange anything.
 
When you can build a function that establishes what type it is based on the pointer?
 
@SSight3 How would it work otherwise?
 
@LewsTherin yes, in TCP it waits for the right packet and tells the other end if it didn't get the right packet
 
TCP will not give you (n + 1)th packet until you've read nth one.
 
3:00 PM
@RMartinhoFernandes Really? What if packets arrive in the wrong order?
 
@RMartinhoFernandes it could work like malloc where you just tell it the size.
 
@LewsTherin They arrive in the wrong order. Deal with it.
 
ah ok
 
@codemaker No, it couldn't. new calls constructors.
 
@SSight3 you have to tell it the type so it knows the size and what, if any constructors to execute
 
3:01 PM
Lemme give an example
 
@RMartinhoFernandes well yes of course, but he may just be thinking it should only need the size
 
@SSight3 What pointer? Are you talking about placement new?
 
template<typename T>
void CREATEB(T * &Item, const size_t Size = 1)
{
Item = new (std::nothrow) T[Size];
}
 
@LewsTherin a lot of protocols pack a sequence number into the packet. That way it can tell if a packet was missed or in the wrong order
 
@codemaker I don't think I'd like UDP lol
 
3:03 PM
@SSight3 You're still giving it a type.
 
@LewsTherin it is good for some things
 
@LewsTherin Well, in most cases, TCP is what you want.
However UDP can be more performant.
 
@CatPlusPlus When I call the function, I merely pass CREATEB(Node);
 
@RMartinhoFernandes I am not sure I would agree with that
 
So when the server writes to a client for example `write(socket,"Hello", 5)`
Is it writing to the client socket or something?
 
3:03 PM
wow, 4 comments at the same time.
 
@codemaker why not?
 
@CatPlusPlus Compared to Node = new char[Size];
 
@SSight3 There is no type deduction on return types.
 
2 more...
 
@RMartinhoFernandes Sorry?
 
3:04 PM
@codemaker Why not?
 
No, what I am saying is, why isn't the new function like CREATE?
Why isn't it just
new node [size];
 
@LewsTherin because that sentence implies a sort of "choose TCP by default" rule of thumb, which may not always be a good idea
 
@SSight3 That's exactly how it is.
 
Why would it take a variable?
 
@RMartinhoFernandes But it isn't.
@CatPlusPlus Node is a pointer.
 
3:05 PM
auto node = new char[size];
 
@CatPlusPlus Why so verbose?
 
I'm confused now.
@SSight3 Where's the verbosity?
 
Explicit is better than implicit.
 
@LewsTherin when reliability is important, and latency is tolerable, or if your data is stream oriented, TCP is probably the way to go
 
You need: 1) a variable name, 2) a type, 3) a size.
 
3:06 PM
i'm getting bamboozled...
 
Your function has no advantages whatsoever, unless you really want to obfuscate your code.
 
@RMartinhoFernandes Okay, basically, you can do New(Node,Size);, compared to Node = new char[Size];
 
The only thing that could be elided there is the auto.
 
@codemaker Ok thanks, I'll keep that in mind :)
 
> In C++11 a special semantic-glyph "&&" exists, to denote the use/access of the expression's address for the compiler only, i.e. the address cannot be retrieved using the "&"–address-of–operator during the run-time of the program
 
3:06 PM
dejavu...
 
What utter nonsense is this?
 
@RMartinhoFernandes You don't need the type. Clearly. The example I give I don't supply a char.
 
@SSight3 Well, because new doesn't take a pointer. It returns one.
 
@LewsTherin but if latency is more important than reliability, then you want to go with UDP
 
Something else I don't understand:
when the server writes to a client for example `write(socket,"Hello", 5)`
It is writing to client socket, right?
 
3:06 PM
@SSight3 It doesn't make sense. You still have to define the pointer.
 
@RMartinhoFernandes It doesn't need to return anything (or a bool for success/failure - optional though). You use a reference!
 
But now char *n = new char[s]; is char *n; New(n, s);
 
@SSight3 What? Show me a complete example of your hypothetical new.
 
@CatPlusPlus The CREATEB function still does that. Because it's a reference.
 
@LewsTherin transporting a real-time voice stream over the network works better with UDP. Transporting an image from a web server works better with TCP. The best protocol for the job depends on the task at hand.
@LewsTherin well sort of
 
3:07 PM
@SSight3 You need to pass something along.
So you need to define it beforehand.
 
@CatPlusPlus It could be char *n; new n[s];
 
You're just obfuscating the assignment, and gain nothing.
 
@SSight3 How's that any less verbose?
 
@codemaker won't the voice have lots of noise? If UDP isn't reliable. I would imagine TCP for that..
 
@CatPlusPlus Actually I do gain something. I don't have to keep typing what type it is.
 
3:08 PM
@RMartinhoFernandes It doesn't have = so it must be less verbose!
 
@codemaker So the socket has the string "Hello World" from the server?
 
@RMartinhoFernandes How many times do you assign when you create the variable? It wouldn't apply in every instance.
 
@SSight3 How many times do you use new on the same pointer, exactly?
 
@SSight3 I don't think that's the most common scenario.
 
@CatPlusPlus Quite regularly if you have dynamic arrays, linked nodes etc.
 
3:09 PM
@LewsTherin well the socket is an abstraction. When you "write data" to the socket, the network stack and kernel get the data and send it over the network.
 
If you type it all over the place, then you're duplicating code.
 
And consider void f(int* x);. I can just call: f(new int);.
Now call it with your version.
 
@LewsTherin well for real-time voice (not like an mp3 file you want to download), latency is important. You don't want to answer the phone and say "hello?" and then wait 5 seconds before the person you are talking to hears it
 
Output parameters force you to create variables.
 
@CatPlusPlus I think that's a trite argument missing the point.
 
3:10 PM
There is no point.
 
char *n = new char[size]; is not very common
 
There's a reason we don't do that.
 
Especially when char *n is in a class.
 
@codemaker I don't understand :( it sends "Hello World" to what in the OS? I mean surely something must hold the string..
 
There's a reason new looks like it does.
 
3:11 PM
A flawed reason.
 
Also Base* x = new Derived;
 
@codemaker I guess so..
 
Feel free to create a better language.
 
Your version is the flawed one.
 
I just did.
How so?
 
3:11 PM
@LewsTherin with voice, or video, you are transporting a stream of data chopped up into little frames. Like 20ms frames. If you lose one or two of those frames, it's no big deal. But you want to keep up the pace. You don't want to just not send a frame for 1 second.
 
@SSight3 It serves your scenario, and forgets every other scenario.
35 secs ago, by R. Martinho Fernandes
Also Base* x = new Derived;
Do that with yours.
 
@LewsTherin well the string gets copied into a bufffer, or just read from the buffer you pass to write() and sent over the network
 
@RMartinhoFernandes Isn't that a bad programming practice to cast a subclass to a base class?
 
@SSight3 No.
 
Also I won't even start the "lol using dynamic arrays" thing.
 
3:12 PM
That's a rather common scenario.
 
@RMartinhoFernandes In what instance?
 
It's essential to taking advantage of subtype polymorphism.
 
Also
 
But what happens when my computer receives the "Hello World" string?
I am trying to understand why we need a while loop for read
 
3:13 PM
CREATEB((Derived *)Node,2)
Done
 
@SSight3 Oh right.
Much better.
 
Lol.
And with C-style cast.
 
@LewsTherin oh, ok. With a specific question this makes more sense :)
 
3 mins ago, by R. Martinho Fernandes
And consider void f(int* x);. I can just call: f(new int);.
 
Wonderful.
 
3:13 PM
@SSight3 Do this one, then.
 
Call a constructor? Oh yes, touche, but in order to do that
I'd need to rewrite C++.
 
@LewsTherin you need a loop because you aren't guaranteed to read all of the data the first time you call read().
 
@SSight3 What constructor?
 
int has no ctor.
 
I'm just creating an int, not storing it in a variable and passing it along.
 
3:14 PM
The only instance it will fail on is a non-standard constructor.
 
And consider void f(T* x);. I can just call: f(new T);.
 
@LewsTherin read() tells you how many bytes it read, if that is less than you were expecting, you can then keep reading until you get the number you were expecting
 
Same crap.
 
Oh sorry? You meant the earlier code?
 
@SSight3 Yeah, that's pretty rare, isn't it?
 
3:15 PM
@codemaker where does read() read from? Does the socket point to a buffer in memory?
 
@LewsTherin the network
 
@RMartinhoFernandes Interesting usage. Studying it for one moment.
 
@codemaker Network as in from the wire or air? :S lol sounds stupid I know :O
 
0
Q: how to AOT (ahead-of-time) compile a c++ program

user1018567I'm new to AOT compilation and I was wondering if someone could post a complete example of how to do a sample "Hello, world!" in c++ using LLVM and clang. I looked on the llvm.org website and cannot find any documentation on how to do AOT compilation using llvm. Basically I'm interested in learni...

 
3:17 PM
@LewsTherin there are a bunch of layers of abstraction. The data is read of the network by the network drivers/kernel/network stack and stored in a buffer that you will reference through your "socket". When you read() the network stack copies the data from it's internal buffer into your buffer. It is also possible for there to be no data in the internal buffer and the network stack may then wait for data to come over the wire from the network.
@LewsTherin well the data comes over that ethernet cord plugged into your PC. Or in the case of Wifi (or some other wireless network) it does come over thin air :)
 
@codemaker The air could also be thick! ;)
 
@RMartinhoFernandes I would say it breaks RAII, and that passing malloc'd pointer to a function is counter-intuitive (does the function free it? What if it wasn't malloc'd in the first place?) and why would you need to pass a malloc'd pointer to uninitialised memory when f(int x) would perform the same role? I might be missing the point here.
 
lol
 
@SSight3 It breaks what?
 
new is not malloc.
 
3:19 PM
new does not do RAII.
 
@codemaker I guess read keeps a pointer to the next element in the internal buffer?
 
@SSight3 The function takes ownership of it.
 
@RMartinhoFernandes The function may receive a non-malloc'd int.
 
@SSight3 Stop saying malloc.
std::unique_ptr<T>(new T)
std::shared_ptr<T>(new T)
 
user784668
@RMartinhoFernandes: calloc
 
3:20 PM
@RMartinhoFernandes Memory allocation. That's what new does, allocate memory.
 
abcalloc
 
while(read(sockfd,buffer, strlen(buffer)) > 0) This is the code and I think it is strange... what if there is no data. It should break, but it waits. So I assume there is timer as well?
 
@SSight3 No, it's not.
 
It doesn't 'new' something so I say malloc.
 
That's operator new.
 
3:21 PM
malloc is a name of a libc function.
 
@RMartinhoFernandes It does. How do you get memory from the heap if you aren't allocated any?
 
@LewsTherin heh, no. The read() function passes in a buffer for the stack to copy the data into. It also passes a socket fd so the network stack knows which socket to read from.
 
Malloc is also short hand for memory allocation.
 
@LewsTherin no, there is no timer
 
No, that's silly.
 
user784668
3:21 PM
malloc is something akin to a trolloc?
 
@LewsTherin it will wait for data or it will just fail
 
@Fanael No. Hah.
 
Nobody says malloc without talking about C malloc.
 
@LewsTherin also strlen(buffer) is wrong, should be something like sizeof(buffer)
 
Whatever.
2 mins ago, by R. Martinho Fernandes
std::unique_ptr<T>(new T)
 
3:22 PM
@CatPlusPlus If I meant the C malloc I'd say malloc().
 
Anything wrong with that?
 
Also new is not only allocation.
 
It's no longer a nameless function.
 
@LewsTherin you can make the socket non-blocking so that if there is no data it will fail right away. Also you can use poll() (or select(), but don't use select()) to wait until there is data available
 
It's a well defined call.
Do you think that's not a valid use case as well?
 
3:23 PM
@codemaker I tried sizeof(buffer) and it didn't work. read() copies a number of bytes into my buffer. Then it returns, the next loop it may copy the next byte, but it doesn't overwrite previous contents...so I assume it has to keep track somehow
@codemaker If read() doesn't use a timer, then I think that is weird...
 
@LewsTherin right, so you need to make your loop smarter. Track how much you read, then do read(sock, buffer + read_data, sizeof(buffer) - read_data)
 
user784668
I've made my own linked list class!
 
@Fanael success!
 
@RMartinhoFernandes Does the unique_ptr handle deallocation?
 
@SSight3 That's the whole point of unique_ptr!
 
user784668
3:25 PM
Now you guys will kill me, I think.
 
@LewsTherin this document may be useful for you beej.us/guide/bgnet/output/html/singlepage/bgnet.html
 
@RMartinhoFernandes Then why does it not handle allocation also?
 
@codemaker That's the thing, I don't need to track it! It does so for me already :S It doesn't overwrite previous data
 
@SSight3 Because then you can obtain pointers from other places.
 
@codemaker that's what I am using :)
 
3:25 PM
@LewsTherin it's not doing what you think
@LewsTherin ahh ok good
 
And you can std::unique_ptr(new T(a,b,c));
 
@codemaker UB?
 
@RMartinhoFernandes Is that wise given double-free potential?
 
@SSight3 Because it's silly to impose arbitrary restrictions on that.
 
@SSight3 Of course it's not wise to give exclusive ownership of a pointer to two objects. That's besides the point.
 
3:26 PM
@CatPlusPlus And people wonder how I can claim no bugs...
 
You claim no bugs, because you suck at finding them.
 
I can claim no bugs too. And I'd be lying.
 
Sorry, but it's true.
 
@LewsTherin no, strlen(buffer) will tell you how long the string in the buffer is
@LewsTherin you need to be telling read() how much space is in the buffer
 
@CatPlusPlus I am systematic in my testing of the program. I test each function individually, using normal, extreme and erroneous input. You assume much about my character.
 
3:28 PM
Right.
Believing your code has no bugs makes you a bad developer.
 
Okay, show the code, then.
 
@LewsTherin maybe it would make more sense if I saw the rest of the code. Not sure though.
@SSight3 that must take forever... unless you just put everything in one big function! Brilliant!
 
user784668
My code has never had any bugs, period.
 
@CatPlusPlus It is incomplete, but I can pass you the template array class if you wish? It requires a number of headers.
 
@Fanael when ever I find a bug... er a feature. I rewrite the specification to define the "new behavior" as a feature.
 
3:29 PM
@codemaker I'm using the template given to me by my lecturer...almost the same ideone.com/QWJHp
 
@codemaker The "malloc'd behavior", you mean.
 
@codemaker It's quick. Testing the foundation functions usually means the functions that rely them don't need to worry.
 
@LewsTherin oh, yeah he has sizeof there
 
user784668
@codemaker : exactly.
 
@SSight3 wait, but you said you tested every function... I see what you did there :)
 
3:30 PM
@codemaker No I changed it :) lol and it works now...but I am still passing the buffer as it is
 
@SSight3 Er, template array class?
 
@CatPlusPlus A std::array clone, I presume.
 
You mean, like, std::array which could be written in 15 seconds?
 
@LewsTherin yeah, that should be fine
 
But okay, show it.
 
3:31 PM
@LewsTherin you may want to fire up wireshark and watch as your data goes over the network. It might blow your mind.
 
@CatPlusPlus Dynamic array class if you prefer. Closer to vector. Kind of. You can self-assign (if you must), you can append to itself, append individual items, or remove individual items, or if you feel insane enough, you can remove it from itself.
 
Remove it from itself?
 
I don't understand why? Why does it not overwrite previous data? Unless it keeps tracking using an index :S
Lol my mind is already BLOWN TO PIECES! :D I have to use that by the way
 
@CatPlusPlus Shut up, laugh and let him show it.
 
Okay, okay. :(
 
3:33 PM
@CatPlusPlus Yes. So if you had a container called Array that had "char", and you did Array -= Array, the result would be a manually removed empty array. Pointless, but added lest anyone decided to do that.
 
@LewsTherin well it overwrites "buffer", the item you pass to it, but internally it knows what you read already
 
BRB
 
@LewsTherin just like when you read from std::cin (or use scanf()) you don't keep reading the same data
 
Oh, right, the array arithmetic. How could I forget.
 
3:34 PM
Robot's broken.
 
@codemaker That doesn't make sense to me. I write 5bytes to my buffer, then the next loop I write another couple of bytes, passing the beginning of the buffer again. But are you are saying it figures out how many bytes it has written already? So it knows where to continue?
 
@LewsTherin lol, im sensing some gaps in your mental model of how a network works
@LewsTherin but you are calling read(), read() doesn't write stuff
 
@codemaker It does, to my buffer?
@codemaker I understand little about it :O
 
@LewsTherin I suspected you would say that :)
@LewsTherin and it overwrites your buffer each time
 
@codemaker lol well it does.
@codemaker yes exactly! So why is that it doesn't appear to overwrite my buffer when I print it after the loop?
 
3:37 PM
@LewsTherin it doesn't know anything about the state of your buffer. It is just like "huh? you want me to stick it in there? ok I can do that."
@LewsTherin because you print from the buffer each time you read
 
@codemaker That's what he said.
 
@RMartinhoFernandes over and over again
 
That's what she said.
 
@codemaker But then if I do it the way you suggested read(sock, buffer + read_data, sizeof(buffer) - read_data)
I would have many copies?
or as much as the loop runs for..
 
What is C++/CX?
 
3:39 PM
@FredOverflow What? Where?
 
@LewsTherin maybe, depends on how you did it. If you printed the buffer each iteration of the loop you would see the same data printed over and over with more data appended each time
 
Oh, it exists.
 
8
Q: Can C++/CX simplify my (non-WinRT) WPF application?

JeffC++/CX seems to make interfacing native C++ with C# FAR easier and more direct than the current method using a C++/CLI 'layer' in-between (with all the complications that entails). But can I use C++/CX OUTSIDE WinRT in a old-school WPF Desktop-style Application? Clarification: My WPF App 'wraps'...

 
The files you should need in order to run TemplateArray.h:
[ErrorMessage.h](http://ideone.com/KSdGq)
[MemAlloc.h](http://ideone.com/D6Pa8)
[CommonFunctions.h](http://ideone.com/MiLa7)
[TemplateArray.h](http://ideone.com/HUpwl)

In anywhere I expect either common functions (pointer syntax is always my downfall) or some sort of technical expert programmer trick to break.
 
3:40 PM
@LewsTherin you are printing the buffer each time you loop, not after the loop. So you read -> print -> read -> print -> read -> print
 
> you cannot use C++/CX outside WinRT - it relies on the windows runtime metadata and there is no metadata for non winrt APIs.
 
Oh, is that what they call the WinRT extensions?
 
@FredOverflow It is another C++ extension to target the new WinRT API for Metro apps on Windows 8
 
Hi all
 
@codemaker I tried it both ways, and it works!
or appears to :(
 
3:40 PM
@Mahesh Hello
 
@Praetorian That only opens up a can of other questions :) What is WinRT? What is Metro? When is Windows 8?
 
OMG malloc!
And memset.
 
@Mahesh I'm having rice pudding ATM.
 
Are you sure this is C++?
 
@RMartinhoFernandes The older functions. I use CREATEB mostly.
 
3:41 PM
@LewsTherin probably because when you print after the loop, your loop only called read() once
 
	printf("Current date and time: ") ;
	while(read(sockfd,buffer, sizeof(buffer)) > 0)
	{
		//printf("%s", buffer) ;
	}

	printf("%s", buffer) ;
 
@RMartinhoFernandes Backwards compatibility.
 
@SSight3 Oh, I see now.
 
RETURN_VOID
 
@RMartinhoFernandes With my own terrible coding practices before.
 
3:41 PM
@FredOverflow You still remember it :)
 
@codemaker I tried it also printing a new line after each read, it definitely calls it more than once ... but good point
 
There, I found one.
 
@FredOverflow Metro is the design language - that's Microsoft speak. It is basically the UI design paradigm for Windows Phone 7, and WinRT is the new API they came up with to create Metro apps on Win8. I have no idea when the OS is being released
 
void Clear(){Size = 0; Array = NULL;}
 
3:42 PM
@CatPlusPlus returns void. As return void; It's there a placeholder so if I want to put errno = EIO; return void; instead it will modify all the functions.
 
Can we move on to more interesting pastures now?
 
@RMartinhoFernandes That's a bug why?
 
Why the hell do you touch errno.
 
@Mahesh How could I ever forget? ;)
 
@SSight3 It's a leak.
 
3:43 PM
std::auto_ptr<int> p1(new int(5));
std::auto_ptr<int> p2 = p1; // Why is that snippet considered as "move semantics"?
 
ideone.com/D6Pa8 This is nigh unreadable.
 
@codemaker ok you are right...it does call read once... but
 
@LewsTherin if you want to see exactly what is happening, stick it in a debugger and step through your loop and look in the buffer each time. It could blow your mind ...again! :)
 
@FredOverflow The only cool thing about C++/CX is that it all compiles down to native code. But I really wish it wasn't another extension; instead a custom preprocessor lile Qt's moc would've been better
 
Also you should not use nothrow new.
 
user784668
3:43 PM
@CatPlusPlus: my eyes are bleeding.
 
@Mahesh Because p2 steals the int from p1.
 
@Mahesh auto_ptr simulates sort-of move semantics.
Only badly.
 
@RMartinhoFernandes Clear(); is protected. It's only used in context of open(), which is a constructor for malloc ops, and close(), but only after deallocation occurs. IE, you'd have to purposefully call open(). Reset() should be used.
 
It can also be in used in the context of what not.
It's not private.
 
Help me guys to understand the terminology "move semantics" !!!
 
3:44 PM
Reimplemented <algorithm>, only with no genericity.
 
does nothrow new just return NULL?
 
@codemaker I can't use a debugger with ubuntu, ugh :(
 
@codemaker Yes.
 
@LewsTherin why not?
 
Apparently sizeof() and strlen() make read behave differently
 
3:45 PM
12
Q: What is the origin of the term "baller" which means "pointer"?

HarveyI've seen the term "baller" used in a couple of C++ interview tests. It means "pointer" as best as I can tell from questions like "Describe the difference between a baller and a reference." I thought that perhaps it was an Indian term due to some Google deduction, but a couple of Indian co-worker...

 
@codemaker Returns NULL when there's an error. Which helps if I just want a true/false return.
 
lulz
 
operator const bool () const; is another bug.
 
I don't know how to.. and it looks weird if I remember from last year
 
Google for safe-bool idiom.
 
3:45 PM
std::unique_ptr<int> p1(new int(5));
std::unique_ptr<int> p3 = std::move(p1); // This was what auto pointer copy constructor is doing. Why do we need some new terminology called move semantics in C++11
 
@LewsTherin well yes and no. strlen() is not what you want there and might even cause your program to crash in that case
 
@RMartinhoFernandes It should be protected. I mandated that Clear(); should be protected (protected for subclass usage).
 
@Mahesh Yes, that is kosher move semantics.
 
@SSight3 I can write subclasses and the destructor is not virtual?
 
3:46 PM
@CatPlusPlus Explain?
 
@SSight3 im not sure why you would want a true/false return based around memory allocation, but I don't really want to know
 
catch (...) is bug waiting to happen.
 
@codemaker How do you mean by "yes and no"? It makes the read 25 times lol and sizeof() only once! And you are right it overwrites the buffer. Nice one dude
 
@SSight3 Function definitions in header files without inline.
 
user784668
@CatPlusPlus so what? True programmers use one, single, big TU.
 
3:46 PM
@LewsTherin get your learning pants on, you are about to learn how to use a debugger in ubuntu
 
@FredOverflow Could you please see the update ?
 
@codemaker lol is there time? I have 20 mins left of library time :(
 
@codemaker So I can fulfill the 'quit on first error' rule with if statements. Or in this case, if statements in the form of error reporting macros.
 
@Mahesh Have you read this?
31
Q: Can someone please explain move semantics to me?

dicroceI just finished listening to the Software Engineering talk radio podcast interview with Scott Meyers regarding C++0x. Most of the new features made sense to me and I am actually excited about C++0x now, with the exception of one. I still don't get "Move Semantics"... What are they exactly?

 
void TransferFrom(TemplateArray &ItemCopy) is syntax error, you're using class template name without template arguments.
 
3:48 PM
@FredOverflow I thought inline only applies for single-line (or similar) functions? It shouldn't be needed.
 
@SSight3 yeah... we see things differently. Would an exception not quit in the same spot?
 
Duplicated code, duplicated code, duplicated code.
 
@CatPlusPlus No, that's valid.
 
@CatPlusPlus It compiles. It's inside the class. That's why I write functions inside the class.
 
You can use the template name to refer to it with the same arguments as are being instantiated.
 
3:48 PM
@SSight3 Function definitions in header files without inline violate ODR. It doesn't matter if they're actually inlined or not. Most compilers will make their inlining decision based on their own reasoning.
 
Oh, didn't know that.
 
@FredOverflow Nope. When ever I google something, the first thread is SO link. But in this case, it isn't. So, I thought it wasn't asked on SO. Get to you back afte reading the thread
 
@LewsTherin well I don't know if you can apt-get install gdb (or if it is already installed). If it is, you can run gdb myapp. Then do b myapp.c:line-no, then do r
 
Or maybe I did, but derp'd. Anyway.
 
@FredOverflow You were challenging about bugs. So far it's only been programming practice.
 
3:49 PM
4 mins ago, by R. Martinho Fernandes
operator const bool () const; is another bug.
This is a bug.
 
Violating ODR is a bug, because the code won't even compile.
 
@codemaker It is installed I will try now
 
@FredOverflow I will do that in future. But that's an optimisation. The code does work.
 
@SSight3 What are you talking about? I didn't challenge anyone about anything. At least not today.
 
@FredOverflow I may be getting confused between people.
 
3:50 PM
It's not an optimisation.
 
@SSight3 No, it's NOT an optimization! Without the inline, your code violates ODR, period. It has nothing to do with inlining. I know that sounds strange.
 
user784668
@RMartinhoFernandes: this is a feature.
 
@Fanael Bug.
 
2
Q: putting function definitions in header files

FredOverflowIf you want to put function definitions in header files, it appears there are three different solutions: mark the function as inline mark the function as static put the function in an anonymous namespace (Until recently, I wasn't even aware of #1.) So what are the differences to these solutio...

 
Also, const-qualifying return values is meaningless.
 
3:51 PM
A vector that is convertible to char is a bug.
 
@CatPlusPlus on scalar types
 
@codemaker no debugging symbols found
 
user784668
@RMartinhoFernandes: there are no bugs, only features.
 
Well, yes, I'm commenting on all those const bool foo()
 
@LewsTherin build with -g
 
3:52 PM
@CatPlusPlus GCC warns me about that.
 
@CatPlusPlus Yes, those consts are meaningless.
 
user784668
@codemaker: I'd recommend -g3 instead.
 
those const bool foo() things are only bugs if he includes the file more than once
@Fanael or -ggdb3
@LewsTherin so yeah, do that instead "-ggdb3"
 
I'm not even trying to read the function bodies, unreadable.
 
@codemaker so gcc -ggdb3 myapp myapp.c ?
 
3:53 PM
@CatPlusPlus you are going to drive yourself mad
@LewsTherin gcc -ggdb3 -o myapp myapp.c
 
A bug in a macro!
 
If I saw ERRORCLASSFUNCTION(TemplateArray,Remove,Data == NULL,RETURN_BOOL) in production code, I'd blame and then smack the person responsible.
 
@CatPlusPlus And that macro is buggy!
ERRORCLASSFUNCTION(TemplateArray,Remove,Data == NULL,RETURN_BOOL) else { something } is valid.
 
@codemaker that worked "Reading symbols from dir..." and that was it
but it is showing (gdb)
 
user784668
@codemaker I was always writing -g3 -ggdb, good to know there's -ggdb3.
 
3:55 PM
Oh, right.
 
@Fanael i don't know if that will do the same thing as -g3 and -ggdb, check the docs
 
Also hardcoding error reporting as printf calls.
 
Oh, there's errno in there.
OMG.
 
user784668
@codemaker: it looks like it will.
 
@LewsTherin right, now run those other commands (b myapp.c:<line>, then r)
 
3:56 PM
I saw that errno earlier. :P
 
Do you know that you must set errno to 0 before making a call?
 
Internet connection dropped out.
 
@RMartinhoFernandes So where is the bug count now? :)
 
I can't find errno = 0 anywhere.
 
@LewsTherin in place of <line> put the line you want it to stop on. Say the line the while() loop is on
 
3:57 PM
@FredOverflow > 0.
 
@codemaker oh my God, hex numbers. God!
 
@RMartinhoFernandes I figured :)
 
@LewsTherin hex?
 
Breakpoint 1 at 0x8048709: file clientside.c, line 54.
 
@LewsTherin oh right :)
 
3:57 PM
@RMartinhoFernandes ERRORCLASSFUNCTION is supposed to be an if statement, so using else is valid. As is also omitting any of the other arguments bar the third.
 
I still fail to see the utility of the enitre thing.
 
@codemaker I assume that is the line address?
 
@LewsTherin after you run "r", the program will run then stop at the break point. Then you can use print to print values. "print buffer", will show you what is in buffer
 
@SSight3 Sure, right.
 
All of these can be replaced with std::vector.
 
3:58 PM
Have you tried actually running it? All I see are design compliants.
 
@SSight3 It doesn't compile.
 
@LewsTherin im not sure what that is. Probably the address of the first instruction for that line or something
 
That's a requirement for running.
 
@RMartinhoFernandes What's the error?
 
@SSight3 ODR violations.
 
3:58 PM
We already told you why.
 
@SSight3 We don't run code in the Lounge. That's just not interesting at all.
 
@codemaker mmn ok, so I should type print buffer in command line? lol or in the loop
 
@RMartinhoFernandes You using a technical argument. ODR doesn't apply. Actually, it compiles for GCC 4.3 onwards.
 
What.
 
You know what?
 
3:59 PM
@LewsTherin command line
 
How does ODR not apply? lol
 
If it compiles, then you're using it only in a single TU.
 
@CatPlusPlus It compiles. It works. It's fine.
 
@codemaker Oh and I thought that was a stupid question
 
There's a comedy group here, with a sketch where a politician in a debate complains the opponent used an argument!
 
3:59 PM
@LewsTherin you can also do print sizeof(buffer), print strlen(buffer) or you can print anything else
 

« first day (377 days earlier)      last day (4578 days later) »