The weirdest bug I’ve found in a compiler: MSVC 2017
1–10 of 61 posts
Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#2Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#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 something) it's a pity that the author hasn't investigated a little more. Even not knowing the meaning of the lines I've quoted, the symptoms look somewhat familiar to me with these "special behaviors" of identifiers.
Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#4template 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…
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
Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#5Anyway, does anybody still have this article somewhere? I couldn't find it anymore :(
Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#6template 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…
Either of which could apply to 'U{}'.
decltype is just returning the result type of the contained expression, which is the return type of the method 'func' called on a default or value initialized instance of type U. A lot of times people will use std::declval() instead which returns a reference to U w/o needing to call a valid constructor (https://en.cppreference.com/w/cpp/utility/declval).
The templated using statement is creating a template type 'func_type' which is similar to a typedef.
Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#7template 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…
class Foo {
int func();
};
// func_type = int
Also, for more info, see http://en.cppreference.com/w/cpp/language/type_alias, https://en.cppreference.com/w/cpp/language/decltype.Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#8I 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…
Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#9Re: The weirdest bug I’ve found in a compiler: MSVC 2017
#10template 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…
I can't guarantee I'm right, but AFAIK that's sort of a templated typedef, where the bound type is that of the return value of method "func" of class U. Short example: class Foo { int func(); }; // func_type = int Also, for more info, see http://en.cppreference.com/w/cpp/language/type_alias , https://en.cppreference.com/w/cpp/language/decltype .
template
using Vec = vector>; // type-id is vector>
Vec v; // Vec is the same as vector>
That explains to me the using construct.And tcbawo's answer tries to address the U{}.func()
However "either of which could apply to U{}" ... I'd expect that it should be possible to say which of these is in this example? I also can't see how that can (or should?) match "aggregate_initialization."