Live data from Hacker News

The weirdest bug I’ve found in a compiler: MSVC 2017

medium.com

11–20 of 61 posts

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#11
post #4
post #3

template using func_type = decltype(U{}.func()); I admit I'm not following all the new stuff that is added to C++. What are that two lines supposed to mean? I don't know what the U{}.func() and using x = decltype() constructs should mean or their names. The names of these and links highly appreciated. Thanks. Moreover, regarding the "bug": if "U" is actually special as an identifier (e.g. some predefined macro or som…

Didn't you read the rest of the article? They tested with arguments with different names. Further they showed that T was accessible from within the other template when it didn't have a template parameter T, making this even more bizarre. Also, just to be completely sure, I tested it myself. Using X: https://godbolt.org/g/B9YEgZ Showing the template parameter leaking with neither T nor U: https://godbolt.org/g/CKe2wG

I know that’s a detail, but if I’m not mistaking the author is only one person, not sure why you wrote your comment in plural form (that personally slightly confused me).

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#12
post #11
post #4

Earlier quoted context omitted.

Didn't you read the rest of the article? They tested with arguments with different names. Further they showed that T was accessible from within the other template when it didn't have a template parameter T, making this even more bizarre. Also, just to be completely sure, I tested it myself. Using X: https://godbolt.org/g/B9YEgZ Showing the template parameter leaking with neither T nor U: https://godbolt.org/g/CKe2wG

I know that’s a detail, but if I’m not mistaking the author is only one person, not sure why you wrote your comment in plural form (that personally slightly confused me).

I am a purveyor of singular they, lacking any other good gender-neutral way to refer to a singular person in English.

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#14
post #3

template using func_type = decltype(U{}.func()); I admit I'm not following all the new stuff that is added to C++. What are that two lines supposed to mean? I don't know what the U{}.func() and using x = decltype() constructs should mean or their names. The names of these and links highly appreciated. Thanks. Moreover, regarding the "bug": if "U" is actually special as an identifier (e.g. some predefined macro or som…

The expression is defining a type named func_type whose type value corresponds to the return type of the member function named func() in the given type.

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#15
post #12
post #11

Earlier quoted context omitted.

I know that’s a detail, but if I’m not mistaking the author is only one person, not sure why you wrote your comment in plural form (that personally slightly confused me).

I am a purveyor of singular they, lacking any other good gender-neutral way to refer to a singular person in English.

[deleted]

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#16
post #5

I tried remember reading an article on HN a couple of years ago about how MSVC got initial C++ support and added more and more features over time, despite having not being designed with C++ in mind originally. The result was a combination of clever hacks after clever hacks, with the consequence being the reputation MSVC got over time (I'm not saying this is one the consequence shown in the OP) Anyway, does anybody st…

I'm a two decade Windows developer so this isn't a "M$ Sucks" comment, but Windows itself is a series of hack on top of hack because Microsoft refuses to break backwards compatibility.

As much as MS had the reputation of "Windows isn't done until Lotus won't run" back in the day. If you follow some of the MSDN blogs, you'll find the extraordinary hacks that MS has done over the years to keep the most obscure programs running.

People complain about how Apple will drop support for backwards compatibility but this a consequence of the MS culture of doing just the opposite.

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#17
post #4
post #3

template using func_type = decltype(U{}.func()); I admit I'm not following all the new stuff that is added to C++. What are that two lines supposed to mean? I don't know what the U{}.func() and using x = decltype() constructs should mean or their names. The names of these and links highly appreciated. Thanks. Moreover, regarding the "bug": if "U" is actually special as an identifier (e.g. some predefined macro or som…

Didn't you read the rest of the article? They tested with arguments with different names. Further they showed that T was accessible from within the other template when it didn't have a template parameter T, making this even more bizarre. Also, just to be completely sure, I tested it myself. Using X: https://godbolt.org/g/B9YEgZ Showing the template parameter leaking with neither T nor U: https://godbolt.org/g/CKe2wG

Sheesh, I'm not exactly obsessed with internet points but I am kinda curious why I got so downvoted. I wasn't really trying to be condescending, but the article kinda does answer this concern (regarding U being reserved) in a couple ways.

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#18
I found years ago that (at least with older versions) VC++ implemented templates essentially as internally generated macros. All the non-standard behaviour they had could be explainined by considering how they would act if they were macros. This bug strikes me as being consistent with that. T is leaking across structs because it is internally #defined and seen by another struct.

I think Microsoft has managed to prop up this massive template-as-macro hack all the way through VS 2017.

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#19
post #8
post #5

I tried remember reading an article on HN a couple of years ago about how MSVC got initial C++ support and added more and more features over time, despite having not being designed with C++ in mind originally. The result was a combination of clever hacks after clever hacks, with the consequence being the reputation MSVC got over time (I'm not saying this is one the consequence shown in the OP) Anyway, does anybody st…

MSVC has had C++ support for a long time, to be fair. GCC was probably just as bad at first, it just improved more steadily over time. Today, GCC and Clang both seem like very robust C++ compilers, and it doesn't feel like MSVC is terribly far behind (it does feels like it is behind, in my perception, just not far.)

Visual C++ has the best C++ among commercial C++ compilers.

http://en.cppreference.com/w/cpp/compiler_support

And the table lacks most embedded compilers.

Re: The weirdest bug I’ve found in a compiler: MSVC 2017

#20
post #17
post #4

Earlier quoted context omitted.

Didn't you read the rest of the article? They tested with arguments with different names. Further they showed that T was accessible from within the other template when it didn't have a template parameter T, making this even more bizarre. Also, just to be completely sure, I tested it myself. Using X: https://godbolt.org/g/B9YEgZ Showing the template parameter leaking with neither T nor U: https://godbolt.org/g/CKe2wG

Sheesh, I'm not exactly obsessed with internet points but I am kinda curious why I got so downvoted. I wasn't really trying to be condescending, but the article kinda does answer this concern (regarding U being reserved) in a couple ways.

At risk of being downvoted, myself, as this is off-topic, but since there is no 'meta' and you're clearly looking to understand what happened, I suspect the issue originates in the first statement made from the original comment, which was posed in the form of a question:

    Didn't you read the rest of the article?
My rule of thumb is that if a question can have ", moron?"[0] appended to it and both the meaning and tone remain unchanged, then it's going to be taken as condescending. You'll probably find that people who are particularly sensitive to keeping Hacker News a "civil place" (among which I count myself) will read that sentence and skip the rest of the comment before hitting the downvote button. Had it been left off, the rest of your comment offered clarity to anyone who simply skimmed the article or otherwise wasn't understanding what was being presented and might have missed that point. Removing the sentence also doesn't affect the information being conveyed[1].

While I'll take you at your word that it wasn't meant as condescending, a variant of Hanlon's Razor[2] applies which I had shared with me as "Where there are gaps of understanding, people tend to jump to the worst possible conclusion." and this serves as a pretty good example. You assumed the reader didn't bother to read the article, when it was equally likely that they simply didn't understand what was being presented -- a fair estimate since this is C++ templates, which is not something everyone encounters in their day-to-day. And folks who are able to downvote likely did so because they assumed you were being condescending, when it's equally likely that you may have simply written the comment hastily or meant the question in a less-sarcastically sounding manner -- a fair estimate since verbal queues are missing from written text and most of us type near the speed that we think.

[0] Or "dumba$$" or "?, God!" (followed by a gesture of hands being thrown down in disgust)

[1] I once had a great manager who, at a yearly feedback session, told me rather bluntly that I am too verbose and worked with me on how to convey a message by learning what is unnecessary for conveying it. As you can tell if you glance through my comment history, the lesson was entirely lost on me. While I'm much better at eliminating things that add negativity to my intent (often by adding more to my statements), I'm pretty terrible at identifying when brevity has higher value than precision and completeness. Though, when it really matters, I can pull it together if I take enough time... and on and on and on.

[2] https://en.wikipedia.org/wiki/Hanlon%27s_razor

Post reply on HN