« first day (870 days earlier)      last day (4086 days later) » 

6:04 AM
@melak47 I actually did when I was making my own "mingw" before it existed, using the DOS port of GCC. I cheated and used CRTDLL.DLL for some stuff though
Linus started on a VIC 20 like me.
maybe people who started on VIC 20's have an increased probability of writing a C standard library?
you can: delete your "scroll through funny pictures endlessly"-BOOK account
@ScottW "To turn off chat sounds, click the gear menu in the chat sidebar and uncheck Chat Sounds"
@ScottW Account Settings > Notifications. Simply click “View” on the top tab and then uncheck the box that says “Play a sound when each new notification is received.”
 
I find myself using uintn_t and intn_t a lot lately.
 
Personally, I prefer tn_t.
It's very effective.
 
what's tn_t
?_?
 
@Rapptz Wooooosh~
 
| Section2 = | Section6 = | Section7 = | Section8 = }} Trinitrotoluene (; TNT), or more specifically, 2,4,6-trinitrotoluene, is a chemical compound with the formula C6H2(NO2)3CH3. This yellow-colored solid is sometimes used as a reagent in chemical synthesis, but it is best known as a useful explosive material with convenient handling properties. The explosive yield of TNT is considered to be the standard measure of strength of bombs and other explosives. In chemistry, TNT is used to generate charge transfer salts. Preparation In industry, TNT is produced in a three-step process. F...
 
6:19 AM
@ThePhD Hm.. I see.
the dy_namite made it clear
You're making a lame joke.
 
<3
I'll be lame whenever you want me to be bby~
 
ahaha.
I accidentally did what I hated the most.
Rejected someone's edit by editing over it.
 
ITT: SO is changing Rapptz into the monster he hates.
 
When will Rapptz get std::regex
 
Wow, this tutorial...
Because there is no return statement, and the function is supposed to return an int, this will produce a compiler error.
 
6:23 AM
wut
 
Probably C89?
 
C++
 
ah.
link?
 
Found it mentioned in a programmers SE question and couldn't resist reading through.
 
Sigh.
Fuck release mode.
Fuck optomizations.
 
6:24 AM
@chris I could've sworn I remember seeing a webpage from that site that lead me to the conclusion that the site is useless for learning C++. Or I might be confusing it with another site.
 
I'm just going to release on /O0 and with debug information and exit if a debugger is ever detected.
 
It can be an error, sure, but you'd think they'd at least mention what you need to do to make it a compiler error.
 
@chris He's right though.
wait which line
I was reading this and realised it isn't even what you mentioned
> In the third statement, ReturnNothing() returns void. It is not valid to pass void to cout, and the compiler will give you an error when you try to compile this line.
 
#2
 
Good morning, niggas.
 
6:25 AM
@ThePhD Or you can try actually understanding the problem and fixing it at the source?
 
It's just undefined behaviour per the standard. Compilers do a good job of warning, though.
 
@ThePhD I ask because I'm actually curious about what's causing the optimizations to completely bork the code generation.
 
user1357851
 
@chris I still don't think he's wrong
(Consider the fact he was using MSVC2005 when he wrote this initially and later updated to MSVC2008, read: fucking old)
 
if your audience barely even knows what a return value means, you can't go into details about it
 
6:28 AM
If you want an example of not a compiler error, here.
 
@Insilico Probably another site. AFAIK this site is actually Not That Bad™
@chris I know it doesn't compile error on GCC.
But it could have error'd on MSVC 2005 or 2008.
 
@Rapptz Most likely. That site isn't bad, the site I was thinking of had mismatched new[] and delete. -__-
 
it's stupid to just have a warning for that
 
@chris Also -Werror :P
 
@Rapptz, Yeah, that's what I was thinking, but it deserves a mention.
 
6:31 AM
funny how you have -pedantic in there, yet you want (TO TEACH new people) that there is UB with no error
 
Anyway, MS's CTP gives an error. It might be a bit dumb, but by not letting it be UB at all, it's not conforming. A warning is good if you listen to it, and -Werror is one of the best flags you can use.
 
I don't know, I mean I don't see that statement being harmful or actually a full lie.
 
hey anyone know anything about stackoverflow.com/questions/15195840/…
 
Now that I mention it, I have no idea what you're trying to prove other than some guy's tutorial is crap
 
Seems like a good way to teach "Hey, don't forget to return something if the function has a return type"
 
6:32 AM
can you friend std::default_delete<MyUserDefinedType> and get the desired effect?
 
When I teach that, I tell them that if they forget, they could spontaneously combust.
 
I don't know why I don't use -Werror actually.
When I see warnings I fix them anyway.
Might as well make it error. Then again it still doesn't matter.. I treat them the same.
 
I can't imagine teaching brand new programmers. I'd stand up front on the first day and say, "Look, if you haven't already taught yourself some programming, you probably won't like this course"
 
@doug65536 The only real way for me to teach brand new programmers I can think of is to basically throw at them a bunch of examples and hope they pick it up
 
Teaching new programmers seems fun.
 
6:36 AM
Total beginners learn through imitation, after all.
 
you'd get a good laugh at what they write sometimes I bet
 
Isn't that part of the fun?
 
Well, the statement I quoted is definitely not the worst.
 
In the fields of education and operations research, the Dreyfus model of skill acquisition is a model of how students acquire skills through formal instruction and practicing. Brothers Stuart and Hubert Dreyfus proposed the model in 1980 in an influential, 18-page report on their research at the University of California, Berkeley, Operations Research Center for the United States Air Force Office of Scientific Research. The original model proposes that a student passes through five distinct stages: novice, advanced beginner, competent, proficient, and expert. The original five-stage model I...
 
It wasn't even wrong.
 
6:37 AM
Not many things call << the output operator.
 
it's not a bad name though. beats saying "left shift" when speaking about outputting strings
 
what would you call it for a beginner?
 
Insertion op.
 
At least insertion. The book my teacher used did that and everyone got it fine.
 
not bad I guess
 
6:39 AM
@Rapptz Beginners are typically not taught bitwise operations until much later, so calling it an insertion operator at this point is fine.
 
"insert" typically means "putting a new item at an arbitrary location" right?
 
For all they care, it's a magical thing that prints stuff to the screen.
 
That book was actually decent with warning about undefined behaviour and things as well. I'm pretty sure it mentioned that letters are not guaranteed to be contiguous pretty early on.
operator begin template arguments begin template arguments
 
"left triangular thing, left triangular thing"
 
ostream operator<< overload
 
6:41 AM
"tepee tipped over to the left, tepee tipped over to the left"
 
sizeof... is so nice
 
user1357851
 
user1357851
your dog can be persuaded by bacon too? :)
 
Hey sorry to bug guys! are any of you top language lawyers and have some time? I'm curious about stackoverflow.com/questions/15195840/…
 
user1357851
T-bones
 
user1357851
6:48 AM
cute
 
@StephenLin you tried it and it worked, right? (just curious)
 
user1357851
@ScottW if your dog bull cross golden retriever?
 
it worked for the guy that wanted it, and i'm sure it probably works in most implementations
i'd be surprised if the standard allowed it though
it seems like it would limit implementer's flexibility too much
let my try it myself on clang trunk and gcc 4.7 real quick
 
user1357851
@ScottW what kind of temperament does your dog have? Bull dogs are aggressive and labs are patient & soft
 
@doug65536 it works clang trunk (libc++) and gcc 4.7.2 (libstdc++)
 
6:54 AM
@StephenLin I can't see a reason why the standard library classes would have any special treatment for that. I'm looking through the C++ standard draft I have and haven't found anything mentioned about deleters or any friend rules for stdlib
 
so it's legal to friend them, but is it defined behavior?
 
0
Q: If a>b, is it possible to set a value to X by max(a,b) = X in C++?

genIf I have two variables max(a,b) returns the higher value. Is it somehow possible to set a variable to the higher value by using max(a,b)? I mean max(a,b) = x; than if(a>b) a = x; else b = x;

 
@StephenLin can't say with certainty, but it would become equivalent to your destructor being public if the deleter is your friend.
 
The Standard algos take by const&. Perfect-forwarding solves that but there was no upgrade to those (it may not be as simple as substituting new versions with regards to backwards compatibility -- and there was some bikeshedding IIRC).
 
@StephenLin it's a compile-time access check. how can it be UB
the deleter is either not allowed to call the destructor (causing compile error), or allowed
 
6:59 AM
@doug65536 meaning is the friendship guaranteed to allow std::default_delete<T> to instantiate on T?
well, right, but is that check guaranteed to succeed or not?
is that well-defined?
 
@StephenLin the constructor could be "deleted" with = delete and friend won't help with that. normal constructors would be allowed
that's the entire purpose of friend isn't it?
 
@doug65536 I'm not sure if I understand you, the friendship doesn't extend to whatever functions std::default_delete<T> calls
 
you're saying to the compiler, "it's ok for std::default_delete<T> to call anything she pleases in this class"
 
also, if std::default_delete is a using alias (i.e. it's actually implemented somewhere else and usinged into std), then the friend will not be well-formed
right, but what if std::default_default uses some external helper function or class to do the job?
why not?
is it prohibited from doing so?
 
> Hmm... this "a vote for me is a vote for ..." thing is something I remember from evan carroll's "nominations". – ThiefMaster♦ 6 hours ago
Did Evan Carroll really run for mod in the past?
 
@doug65536 yes, does it say that default_delete does that delete within the body of the class though?
it might be a defect in the standard if that is not addressed
in theory default_delete could construct a completely different class in a completely different namespace, and have that call the delete instead
 
all it really seems to say is: where you call the operator()(T*) of default_delete, T must be a complete type
 
so I think the issue of friend-ing standard classes is just not addressed at all
which seems to be an oversight
it should be UB, it's too hard on library implementers otherwise because then they cannot refactor or move things to different namespaces
 
They can't move things to different namespaces anyway
 
7:14 AM
they can't using alias things?
i thought they could
put things in an inner namespace and then using in std
 
A using declaration wouldn't work for e.g. explicit specializations. An alias would work for those.
 
well, ok, regardless of the using
 
... then what is left?
 
it seems like default_delete ought to be able to use as much or as little indirection as it wants
it doesn't have to call delete within its class body
and the friendship doesn't extend to anything it calls
 
If you abandon common sense maybe
 
7:16 AM
it implies that is just deletes the T* in there when it says that T must be a complete type where you call operator()(T*)
 
There's absolutely no reason to complicate it
 
You should stop caring. The implementations, by definition, can already do whatever they want as long as user code can't tell the difference. So they don't have to abide by the rules of the language.
If need be, whatever code needs to call the destructor can go __really_please_destroy_regardless_of_access_control(foo) and there you go.
 
right, but the user code can tell, if it's relying on the friendship to make it work
that's not the point, the point is is the user allowed to rely on this to begin with?
 
Fine, use __really_please_destroy_taking_into_account_access_control_of(bar, foo). The solution to a lack of magic is more magic.
 
obviously the implementors could hack the compiler to violate access control for std classes if they wanted to
 
7:18 AM
You lack imagination.
@StephenLin For some things, yes.
See 17.5 Methods of description.
The description of the library includes a bit that describes how descriptions should be interpreted.
(I don't think there's a bit to describe that however.)
(Template) class synopses are quite binding in that respect, which make them tricky to understand (imo).
 
@LucDanton i did say this was a language-lawyer issue, it's not what can be done it's what the standard defines as the semantics
 
Wow.
 
what's the problem?
i really don't understand what you're saying
it's not like i'm doing this myself (I would just write my own deleter) but someone else apparently want to do it and I'm curious if there's any guarantee that it would work
 
Has the algo for the order when displaying answers on SO changed? Or have I been unknowingly using another setting all that time?
 
@StephenLin it mentions: "It is unspecified whether any function signature or class described in Clauses 18 through 30 and Annex D is a friend of another class in the C++ standard library."
 
7:26 AM
Hello again! I'm trying to do some exercises to practice for an in-class "lab" and I'm having trouble freeing my linked list. Here's my very short code:
currentNode = *head;


while(currentNode != NULL){
tempNode = currentNode->next;
free(currentNode);
currentNode = tempNode;
}
Does anyone see an issue?
void freeList(struct record **head) //here is the function header
 
@Vlad looks good
@vlad you need to set *head to null right? otherwise it will point to freed data (at the end of the function)
 
@doug65536 ok well, at least it mentions friendship
 
I do, but if I do that I can't test the rest :)
For now.
So, if I free the data, what are the odds it still prints out the information it used to have correctly? I can still print my list after I "free" the memory. Two columns out of three produce errant output, but one of them is exactly the same?
 
it's undefined behavior if you access freed memory. enable some memory corruption tools and it will probably crash right away as soon as you even touch freed memory (to help you find the bug)
 
I guess my question is, how do I determine whether or not I correctly freed the memory?
 
7:31 AM
@vlad, I meant after the while loop, do *head = NULL;
 
@doug, I do that, so obviously if I try to print my list, it won't work, but I don't know how to determine whether or not the rest of the list was correctly destroyed.
 
you just freed it, you can't print it. nevermind what happens when you try. it might work, or anything can happen
@Vlad tools that help you find memory leaks. there's no (standard) way to "test" whether a pointer points to a valid memory block
@vlad get used to not being "allowed" to do things that "work". it won't always work
 
Ugh using free() :/
Stahp.
 
Ok fair enough thank you. Pointer bugs are the worst..
 
Using raw pointers should be banned
If some people were forced to specify the semantics (i.e. weak, shared, unique), they would at least think about what they are doing
 
7:37 AM
He's using C.
 
djehcdjdbwhdglgbwbrgdblg
 
@Vlad depending on your compiler, they have nonstandard extensions that you can use (strictly for debugging or something) to test whether a memory block is freed or valid or whatever
 
I'm using gcc.
And the only debugger I have at the moment is gdb, which I HATE.
 
MSVC has it. I'm not aware of a way to do the same thing in gcc's libc
 
@Vlad use valgrind valgrind.org
 
@Vlad either you act as the debugger by eyeballing through your code/using the debugger if you like (some people are really good at this), or use valgrind to help detect where your problem is...
 
@Vlad you can define a destructor on your node type and have it print something
is this C or C++?
 
I would love to use valgrind, but I'm literally forced to use gcc for all my in-class projects. C
 
you could always add a destructor and compile it in C++ anyway to test your logic
you probably aren't using anything that isn't compatible between C and C++
 
@Vlad valgrind is not a compiler : you run it on your executable and it will tell you where you have memory issues
 
7:43 AM
you can put a print statement in a constructor and print statement in the destructor and make sure the number of both is equal
 
@vlad are you imposing restrictions on yourself? I doubt the instructor told you that you need to do the impossible
if you really had to, I'd suggest making macros that redirect malloc/strdup/free/calloc/realloc to some function that remembers the block address and calls the real one
 
Sorry, I know valgrind isn't a compiler, but I don't have that tool for my projects, so I try not to use it when I'm studying
 
I strongly doubt any instructor would ask students to do that
 
@Vlad ok - I agree with doug65536 - don't know why you want to be a masochist, but I can't help any more...
 
@Vlad, do you know any C++ at all yet? just do the constructor/destructor thing
 
7:46 AM
He's already mentioned it's C.. not C++.
 
He didn't directly, but if I can't use it for anything that's graded, as I'm forced to use an in-school computer that doesn't have access to these tools, I don't want to use them now
No, I don't no any C++
 
@vlad ah, so you just want a perfect mark then - you don't want him to find a memory leak or bug
 
@Rapptz there's nothing stopping him from compiling C as C++
he can just take the ctor/dtor out when he's done
 
Yeah there is, that'd be moronic.
ISO C++ forbids a lot of shit that is valid C.
 
@doug, pretty much, being as all our graded homework is done directly on school computers, I need to practice with the limitations I am given.
 
7:48 AM
@Vlad your only other hope is do add printf()'s at all pertinent points in your code and do a autopsy on the dump, if you don't want to step thru gdb...
 
if you use MSVC, there is a built in "debug heap" that does it all for you...
 
something is bound to "look strange"
 
Yea, I understand, thanks
 
when the program exits, it prints out all the leaked memory blocks
 
print debugging is for real men
 
7:49 AM
don't worry about doing it (even professionals use printf for debugging)
 
@Rapptz well, i don't know how big of a program he has and how much he's going to really trip on that stuff, but if you say so, that's fine
 
@StephenLin Even basic things like malloc require a cast in C++ when it is perfectly valid in C.
It'll only confuse him further imo.
 
I use printf debugging now, pretty much all I use. I mostly just wanted a way to test my memory to ensure it was freed correctly, but I see now that I need tools that I won't have.
I always cast my malloc calls for clarity
 
@Rapptz ok, sure, i haven't done C in a long time
 
@vlad you have to do it right there in class? you can't bring your code home and test it in your own gcc with valgrind, or recompile it with msvc and use the debug heap?
 
7:50 AM
i don't remember how loose it still is
 
All done in class only... It's quite terrible. Finding bugs is the worst because you have a time limit and if it runs out, your just screwed
 
@R.MartinhoFernandes I'm just catching up on some of your writings. When reading this I noticed you used e.g. TupleElement<I, tuple<T...>>&; out of curiosity I checked my code and there was a single instance that was similar. It appears that most of the time, I use TupleElement<I, Tuple cvref>. I'm not suggesting you change your post of course, it's not incorrect and I think the consideration is irrelevant to the point.
 
shame, would be a good opportunity to do some introductory memory leak troubleshooting and tools course material
 
It still consolidates my view of how I use aliases nowaways. (Oh and of course a straight alias to std::tuple_element wouldn't be able to deal with ref-quals.)
 
I agree, it really doesn't help students learn. It just stresses everyone out without allowing them to think clearly
or use the proper tools
 
7:53 AM
@vlad I'd go for some bonus points and mention to the teacher in private that you wished that they would teach how to use memory leak detector tools. ALL C programmers leak memory all the time, it's almost impossible not to screw it up sometimes in C. C++ is a lot different with respect to leaks
 
@Vlad it's tough, but I think it's not totally insane. For my very first job interview years and years ago, that's how I got my first job: my future boss asked me to sit down at a terminal and write a working program according to his specs. It's actually a good skill to have (doing it under strict conditions)...
@Vlad that boss didn't believe in Q&A for a job interview - he wanted to see me code
 
@kfmf wow, you actually got to use a keyboard? I've had pads of lined paper pushed across the desk. ever wrote C++ with a pen and paper? it almost wipes your brain
 
@kfmfe04 I can see some of the benefits, but mostly I wish I could just take my code home, as a first year student, I'm not entirely comfortable under pressure yet. That seems rather out of the ordinary, but kind of interesting nontheless.
 
@doug655 well, he wanted to guesstimate how I would do on the job - if all he had were paper and pencil and no machines, I surmise that's how he would've done it...
 
Also, how often have you not been able to use every source/tool out there in order to complete you good in a professional enviornment (other than that interview)
 
7:59 AM
@Vlad if you're first year programming, I'd say you're doing well
 
@Vlad well, teaching a programming class is tricky - it's very easy for students to "help each other" too much, nullifying the learning process. I don't know if that's what your instructor is thinking, but anyhow, most of us of have live with rules, whether or not they're reasonable...
 

« first day (870 days earlier)      last day (4086 days later) »