WTF Bites



  • @rhywden you just don't understand Common Core. đŸ€·â™‚



  • @pleegwat said in WTF Bites:

    @rhywden Are they testing for teachers who don't pre-check the tests they put out?

    The fun part is that the included solutions are even more wrong. For example, the answer to question number 2?

    It's "Jazz".


  • area_can

    @rhywden 'More Cars in the Country' is, IMO, Miles Davis' greatest album.



  • @rhywden Having looked up the sourceand it looks like the questions are mixed up between the graphs. This is one of 10 variants . The other variants have different graphs and the other graphs do include columns “Country”, “Interview”, “Fish”, “Gerbil” and “80s”. Like if somebody generated the questions pseudo-randomly with some code, but threw the quantities from all the graphs into one bucket.

    You also forgot to mention the “correct” answers. In the same page, the reasonably sounding question “Of what colour are there exactly two cars” gets the answer of “Jazz”, which somewhat breaks the idea that the columns from wrong sheets were included, because while there is a column with value 2 here—“red”—the column “Jazz” on the previous page has value 9. 😕. The “correct answers” for the previous two question do correspond to the values from previous versions though.

    @rhywden said in WTF Bites:

    The fun part is that the included solutions are even more wrong. For example, the answer to question number 2?
    It's "Jazz".

    Excuse me, that was answer 3 😄 Answer to number 2 is “Country”.



  • @Rhywden from what I've seen of most teacher materials, this isn't so uncommon. The number of just plain wrong things people put out as "educational" is depressingly high. And the number of teachers that don't catch it...well...I'm afraid to ask.



  • @benjamin-hall Yes, but this one really takes the cake. Go, look. There is a page with 10 questions and for all of them either the question or the answer refers to something that is not in the graph and is utterly absurd in context. And there is 9 8 (the first is actually correct) more sheets with comparable quality.



  • @bulb said in WTF Bites:

    @benjamin-hall Yes, but this one really takes the cake. Go, look. There is a page with 10 questions and for all of them either the question or the answer refers to something that is not in the graph and is utterly absurd in context. And there is 9 more sheets with comparable quality.

    The first page for each type of task actually is correct, though. Someone probably messed up their iterators.

    Maybe they used a language which has their iterators out of scope of the for loop? 🚎



  • @benjamin-hall I'll take one exemplary page with me and show it to my colleagues.

    I predict many "Wat."s will be had, coupled with a number of WTF!s when I show them the suggested solutions.



  • @rhywden Yeah, I am seeing it now too. The first page is correct. Then they start to use items from the previous pages—but never the following pages—and go wrong—even if they actually happen to otherwise make sense (on the second page, “which program had exactly 2 commercial breaks” has answer “Jazz”, which is from the right graph, but it had 9 according to it).


  • đŸšœ Regular

    @rhywden said in WTF Bites:

    How many cars were a snake?
    Were there more cars in country or more cars in yellow?
    How big is the difference between the number of cars in a fish and the number of cars in an interview?
    How many more cars are there in interview than in gerbil?
    Are there less cars in the 80s than in a gerbil?

    I think I know who wrote that test:

    0_1522093417138_08212f1e-fb46-4058-b57c-39f3ecaf0ba0-image.png


  • Notification Spam Recipient

    @tsaukpaetra said in WTF Bites:

    @ben_lubar said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    @anotherusername said in WTF Bites:

    @lb_ Can you provide an example?

    This method lacks await operators and will be run synchronously.

    Yes, thanks visual studio, I'm doing this intentionally because the calling function requires an async method and I don't want to put in a dummy awaited task just for that!

    You... do know that Task.FromResult exists, right?

    Nope!

    And I must be doing it wrong, because the only way I can get VS to shut up about my usage of that is:

    await Task.FromResult(true);
    


  • @tsaukpaetra said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    @ben_lubar said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    @anotherusername said in WTF Bites:

    @lb_ Can you provide an example?

    This method lacks await operators and will be run synchronously.

    Yes, thanks visual studio, I'm doing this intentionally because the calling function requires an async method and I don't want to put in a dummy awaited task just for that!

    You... do know that Task.FromResult exists, right?

    Nope!

    And I must be doing it wrong, because the only way I can get VS to shut up about my usage of that is:

    await Task.FromResult(true);
    

    You're supposed to return the value from Task.FromResult. If your function returns a Task instead of a Task<T>, you can use any value. Some versions of .NET have Task.CompletedTask that's less confusing for that purpose.


  • BINNED

    @rhywden said in WTF Bites:

    1. How many cars were a snake?
    2. Were there more cars in country or more cars in yellow?
    3. How big is the difference between the number of cars in a fish and the number of cars in an interview?
    4. How many more cars are there in interview than in gerbil?
    5. Are there less cars in the 80s than in a gerbil?
    1. Does dog have buddha nature?

  • Notification Spam Recipient

    @ben_lubar said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    @ben_lubar said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    @anotherusername said in WTF Bites:

    @lb_ Can you provide an example?

    This method lacks await operators and will be run synchronously.

    Yes, thanks visual studio, I'm doing this intentionally because the calling function requires an async method and I don't want to put in a dummy awaited task just for that!

    You... do know that Task.FromResult exists, right?

    Nope!

    And I must be doing it wrong, because the only way I can get VS to shut up about my usage of that is:

    await Task.FromResult(true);
    

    You're supposed to return the value from Task.FromResult. If your function returns a Task instead of a Task<T>, you can use any value. Some versions of .NET have Task.CompletedTask that's less confusing for that purpose.

    Error	CS1997	Since 'MasterServer.RefreshStatus()' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task<T>'?	
    

    Ah, apparently that's because it's been marked async.

    Now to replace all my early returns with this...



  • @carnage said in WTF Bites:

    But that there stuff is one step above the shenanigans we pulled.

    I admit to having a bit of a hold-my-beercoffee--moment there. UDLs worse than goto? :why-not-both.cpp:



  • @cvi said in WTF Bites:

    @onyx Here's something for you then:

    // Compile with: g++ -std=c++11 -O2 file.cpp -static
    #include <cstdio>
    #include "evil.hpp"
    
    int main()
    {
    	volatile int i = 0;
    
    	500_label;
    	printf( "Hello %d\n", i );
    	
    	if( i++ < 10 )
    		500_goto;
    
    	return 0;
    }
    
    evil.hpp
    #include <setjmp.h>
    
    template< char... > struct Env_ {
    	static jmp_buf env;
    };
    template< char... tChar > jmp_buf Env_<tChar...>::env;
    
    template< char... tChar > inline 
    void __attribute__((always_inline)) operator ""_label() {
    	// g++ refuses to inline a function with setjmp(). But let's not have that
    	// stop us.
    	__asm__ volatile(
    		"1:\n"
    		"movl %0, %%edi\n"
    		"call _setjmp\n"
    		"test %%eax, %%eax\n"
    		"jne 1b\n"
    		: : "g"(Env_<tChar...>::env) : "eax", "edi"
    	);
    }
    template< char... tChar > inline
    void operator ""_goto() {
    	longjmp( Env_<tChar...>::env, 666 );
    }
    

    It "works". For some definition of "work". (Disclaimer: I don't ever recommend doing this.)

    Filed under: Aiming for the front-page.

    Sorry to ask but...

    1. What does evil.hpp do? It looks like a jump, but I don't do assembly
    2. How does that variadic template work? How does jmp_buf not do infinite recursion and how does it store each char on the struct?

  • Considered Harmful

    @rhywden said in WTF Bites:

    WTF of my day: So, some of my pupils have to take a rather basic math test. Including the analysis of basic diagrams, y'know, pie charts, bar diagrams and stuff.

    So I looked around a bit and found some sites which had practice materials for exactly this. One of those sites being named "www.commoncoresheets.de"

    Now, I know that this common core bit is a more of a US'ian thing but they proclaimed that they had translated everything into German (and other assorted languages).

    I'm not quite sure who exactly did the translation. Or maybe what. Could also have been a bunch of monkeys.

    I mean, take this bar graph:

    0_1522088973730_f5fe399b-5780-47a1-8bef-7b08e664dc7c-image.png

    y-axis being the number of cars for a given colour, with the colours (x-axis) being: silver, red, white and yellow.

    There are some questions you have to answer using the diagram. Those questions contain the following gems:

    1. How many cars were a snake?
    2. Were there more cars in country or more cars in yellow?
    3. How big is the difference between the number of cars in a fish and the number of cars in an interview?
    4. How many more cars are there in interview than in gerbil?
    5. Are there less cars in the 80s than in a gerbil?

    :wtf:

    I've always wondered. When you see something translated into another language, you think 'ok, these guys know what they're doing', but how often is the translation absolute shit? What about the instruction manual for my earbuds? Or the tag on my mattress?



  • @magnusmaster said in WTF Bites:

    Sorry to ask but...

    Not sure if you really want to know, because it's pretty horrifying. ;-)

    What does evil.hpp do? It looks like a jump, but I don't do assembly

    The assembly just calls setjmp(); I actually mostly copied the assembly from disassembling a call to setjmp() (Compiler Explorer FTW!). setjmp() is a bit of a weird method -- it stores the current context (values in registers + location on stack), so you can return/jump back to it later, using longjmp(). It's a non-local goto ... The entry on Wikipedia will probably explain it better than I do.

    The problem with setjmp() is that it doesn't work if you call it from a function, return from that function and then do the longjmp(). The longjmp() can only "return" to active function stack frames (i.e., it can only unwind the stack). This prevents writing a simple function-wrapper around setjmp().

    To work around that, I want to force-inline (__attribute__((always_inline))) the function that wraps the setjmp() so that the setjmp() stores the frame of the function from which I "call" the wrapper. GCC very sensibly refuses to take any part in these shenanigans -- it sees the setjmp() and refuses to inline the function. So, I write out the call to setjmp() in assembly, and thereby sneak it past GCC.

    There's a loop around setjmp() -- I'm actually not 100% sure if that's required. Essentially, setjmp() will return twice. First, when it's called initially to store the current context. It will return 0 at that point. Later, when the code returns to the stored context via longjmp(), setjmp() will return again, this time with whatever non-zero value is passed to longjmp(). In that second case, the code will loop once and re-initialize the jmp_buf (which again returns zero and aborts the loop). As mentioned, I'm not sure if this is required.

    How does that variadic template work? How does jmp_buf not do infinite recursion and how does it store each char on the struct?

    The variadic template allows me to have multiple different "labels". So, 1_label would instantiate Env_<'1'>, whereas 137_label would instantiate Env_<'1','3','7'>. Each Env_<...> has its own single static member (that isn't shared with other Env_<something else>). This is the jmp_buf where setjmp() stores whatever state it needs to store.

    Essentially, I can refer to different jmp_buf instances thanks to this. So 1_label will have a separate jmp_buf from 5_label. The chars passed to the Env_ template are not really stored anywhere, they are just used to create an unique type for each different "identifier" (=number that you use), which in turn creates a separate jmp_buf.



  • @cvi said in WTF Bites:

    Env_

    is this documented anywhere



  • @ben_lubar said in WTF Bites:

    @cvi said in WTF Bites:

    Env_

    is this documented anywhere

    What do you mean? It's defined there in the code, it's not some outside library/compiler feature.



  • @lb_ said in WTF Bites:

    @ben_lubar said in WTF Bites:

    @cvi said in WTF Bites:

    Env_

    is this documented anywhere

    What do you mean? It's defined there in the code, it's not some outside library/compiler feature.

    How is it implementing new keywords like that, then?



  • @ben_lubar said in WTF Bites:

    @lb_ said in WTF Bites:

    @ben_lubar said in WTF Bites:

    @cvi said in WTF Bites:

    Env_

    is this documented anywhere

    What do you mean? It's defined there in the code, it's not some outside library/compiler feature.

    How is it implementing new keywords like that, then?

    I don't understand what you mean. Env_ is a template class with a static data member. Did you quote the wrong thing?
    0_1522118991929_16c57ae9-7294-4f21-8f87-180f3a84d17b-image.png



  • @lb_ 500_label; doesn't look like it's part of C++ syntax, is it?



  • @ben_lubar Those are the "user-defined literals" that @Zecc mentioned that started this whole subthread:

    @zecc said in WTF Bites:

    TIL about C++11 user-defined literals.



  • @hardwaregeek said in WTF Bites:

    @ben_lubar Those are the "user-defined literals" that @Zecc mentioned that started this whole subthread:

    @zecc said in WTF Bites:

    TIL about C++11 user-defined literals.

    whaaaaaaaaaaaaaaaaaaaa



  • @ben_lubar A common reaction to C++.



  • @hardwaregeek said in WTF Bites:

    @ben_lubar A common reaction to C++.

    Especially when you take the powerful bits of C++, combine it with the utterly strange bits, and build unholy shenanigans. :D



  • @carnage But when it comes down to it, really, how significant are those bits?


  • Notification Spam Recipient

    @hardwaregeek said in WTF Bites:

    @carnage But when it comes down to it, really, how significant are those bits?

    At least one, sometimes not.


  • Notification Spam Recipient

    Ah, good old YSIWYG post editors, leading users to generate HTML like this:

    0_1522132933101_d772956b-3ef4-4bd4-b1bb-3fc1d0df0451-image.png

    So much better than what we have in the modern age, huh?



  • @pie_flavor said in WTF Bites:

    When you see something translated into another language

    It is not translated. They have a link to other languages and the English version has the same layout and style and type of questions, but the actual questions are different and don't seem to be mixed up.

    It looks like they have some framework for creating the sheets, which is probably a huge pile of :wtf: and the people who did the German version hit some quirk in it—and failed to proof-read the result.



  • @tsaukpaetra said in WTF Bites:

    YSIWYG

    Yakov Smirnoff is What You Get

    What you see: What you get:


  • @ben_lubar said in WTF Bites:

    whaaaaaaaaaaaaaaaaaaaa

    Told you that the dark side was more fun. (Wait till you hear about the meta-classes proposal!)



  • @hardwaregeek said in WTF Bites:

    @carnage But when it comes down to it, really, how significant are those bits?

    Well, the utterly strange bits can be avoided, and powerful stuff will always come with the drawback that they can be abused. I do not quite see the reason to just throw the powerful stuff out altogether because they can be abused. Bad devs abuse everything anyway, so it wont help. :D
    So, i'd say they aren't really significant enough to bother.


  • Discourse touched me in a no-no place

    @topspin said in WTF Bites:

    @rhywden said in WTF Bites:

    1. How many cars were a snake?
    2. Were there more cars in country or more cars in yellow?
    3. How big is the difference between the number of cars in a fish and the number of cars in an interview?
    4. How many more cars are there in interview than in gerbil?
    5. Are there less cars in the 80s than in a gerbil?
    1. Does dog have buddha nature?

    No quack.


  • đŸšœ Regular

    @cvi said in WTF Bites:

    Told you that the dark side was more fun. (Wait till you hear about the meta-classes proposal!)

    Could be cool for stuff like Qt.

    (if one felt like throwing a mature time-tested codebase out the window)


  • BINNED

    @zecc said in WTF Bites:

    @cvi said in WTF Bites:

    Told you that the dark side was more fun. (Wait till you hear about the meta-classes proposal!)

    Could be cool for stuff like Qt.

    (if one felt like throwing a mature time-tested codebase out the window)

    Sutter explicitly mentioned the Qt moc as one example of things he'd rather have the compiler do than a meta-compiler, if I remember correctly. And if done right, only the behind-the-scenes implementation would change, everything else would work just as before.
    Of course, it's a looong way for this to get standardized and even if it were already, Qt would have to wait until all supported platforms implement it. (Meaning, backwards compatibility support for old platforms gets dropped) Don't expect this to happen anytime soon.


  • Banned

    đŸ‘© Please make PR for the feature you're working on, I'd like to see the changes.
    Gąska But I haven't finished it yet. It's not ready for merge.
    đŸ‘© Yes, but it's easier to browse changes that way. We don't have to merge it.


  • kills Dumbledore

    @gąska said in WTF Bites:

    đŸ‘© Please make PR for the feature you're working on, I'd like to see the changes.
    Gąska But I haven't finished it yet. It's not ready for merge.
    đŸ‘© Yes, but it's easier to browse changes that way. We don't have to merge it.

    Next week:
    đŸ‘©: gasket, this change was not ready for merge and broke production. Why did you issue such an unfinished pr?


  • BINNED

    @jaloopa

    Gąska looks around looking for a leaking pipe


  • Discourse touched me in a no-no place

    @jaloopa said in WTF Bites:

    gasket

    :sideways_owl:

    0_1522155416550_2caba6c3-5d99-4000-a7bd-07d59a7393ee-image.png

    0_1522155423756_5079e100-51ca-456f-b4b1-20376d22e7a4-image.png



  • @jaloopa said in WTF Bites:

    gaąsket

    FTFY


  • kills Dumbledore

    @pjh said in WTF Bites:

    @jaloopa said in WTF Bites:

    gasket

    :sideways_owl:

    0_1522155416550_2caba6c3-5d99-4000-a7bd-07d59a7393ee-image.png

    0_1522155423756_5079e100-51ca-456f-b4b1-20376d22e7a4-image.png

    I thought the autocorrect was quite fitting



  • @jaloopa said in WTF Bites:

    @gąska said in WTF Bites:

    đŸ‘© Please make PR for the feature you're working on, I'd like to see the changes.
    Gąska But I haven't finished it yet. It's not ready for merge.
    đŸ‘© Yes, but it's easier to browse changes that way. We don't have to merge it.

    Next weekday:
    đŸ‘©: gasket, this change was not ready for merge and broke production. Why did you issue such an unfinished pr?

    Fixed for reality.

    Edit: Wait, I think I meant "Fixed for Agile"


  • Banned

    From Wikipedia:

    A gasket is a mechanical seal which fills the space between two or more mating surfaces, generally to prevent leakage from or into the joined objects while under compression.

    A condom, basically.



  • The POSIX thread's pthread_mutex_t has had an error-checking mode since time immemorial. Yet when wrapping it in the newfangled C++ class std::mutex, neither GNU stdlibc++, nor LLVM libc++ cares to turn it on at least in debug. Fortunately they rely on the default initialisation, so calling pthread_mutex_init with specific attributes on the native_handle() of a mutex you just created works—but is a butt ugly hack. Hell, the point of using std::mutex was platform independence and this must be inserted per-platform and you have to wrap all the mutexes in your own wrappers to get it and
 :wtf:.



  • @bulb You can at least create your own mutex class that implements the mutex concept - that's at least less hacky than hijacking std::mutex. But I agree, perhaps there are even already some bug reports open for the various std::mutex implementations.



  • @tsaukpaetra said in WTF Bites:

    So much better than what we have in the modern age, huh?

    Yes.

    People look at the post, not the fucking markup.



  • @gąska said in WTF Bites:

    Please make PR for the feature you're working on, I'd like to see the changes.
    But I haven't finished it yet. It's not ready for merge.
    Yes, but it's easier to browse changes that way. We don't have to merge it.

    Wait, what are you using where they can't do their own diff from your branch without a PR?

    FWIW the Atlassian POS I used at a previous company to do PRs had a flag that was like "don't let anybody merge this PR until this flag is unchecked" but probably had a more pithy name.


  • Notification Spam Recipient

    @blakeyrat said in WTF Bites:

    @tsaukpaetra said in WTF Bites:

    So much better than what we have in the modern age, huh?

    Yes.

    People look at the post, not the fucking markup.

    Except the post looks fucking terrible, on literally all devices. It also doesn't match what's displayed in the editor, natch.


Log in to reply