2017-05-28 18:16 GMT+03:00 Ted Unangst <t...@tedunangst.com>: > Vadim Zhukov wrote: >> While working on getting Boost & its friends work under Clang, >> I've stumbled upon the code that looks like the following: >> >> decltype(x, y) z = w; > > why not espie's fix from earlier?
Because I've missed it. :( I have no idea why espie@ did it this way, though... And what's more interesting we shouldn't get into this code when compiling with Clang. This should happen only for old GCCs. See the program: #define _LIBCPP_HAS_NO_DECLTYPE #include <vector> int main() { int x; double y; decltype(x, y) z = y; } If you comment out the first line, it compiles fine under Clang. So basically the problem only raises when the program being compiled plays dirty games with _GNU_VER or something like that... > but clang++ has variadic macros, like C99... the following patch allows > macro decltype() to work a lot more like builtin __decltype in pre-C++11 > > (note that still works with -std=c++98 -pedantic, much to my surprise, but > which is cool) > > Index: __config > =================================================================== > RCS file: /cvs/src/lib/libcxx/include/__config,v > retrieving revision 1.3 > diff -u -p -r1.3 __config > --- __config 19 Sep 2016 22:17:22 -0000 1.3 > +++ __config 5 May 2017 15:21:58 -0000 > @@ -670,7 +670,7 @@ template <unsigned> struct __static_asse > #ifdef _LIBCPP_HAS_NO_DECLTYPE > // GCC 4.6 provides __decltype in all standard modes. > #if !__is_identifier(__decltype) || _GNUC_VER >= 406 > -# define decltype(__x) __decltype(__x) > +# define decltype(__x, ...) __decltype(__x, ##__VA_ARGS__) > #else > # define decltype(__x) __typeof__(__x) > #endif > -- WBR, Vadim Zhukov