On Mon, Aug 18, 2014 at 11:39 AM, Joey Ye <joey.ye...@gmail.com> wrote: > On Fri, Aug 15, 2014 at 6:33 PM, Richard Biener > <richard.guent...@gmail.com> wrote: >> On Fri, Aug 15, 2014 at 10:45 AM, Joey Ye <joey.ye...@gmail.com> wrote: >>> Running into an unexpected result with GCC with following case, but >>> not sure if it is a valid C++ case. >>> >>> #define nullptr 0 >>> enum nonetype { none }; >>> >>> template<typename T> >>> class class_zoo { >>> public: >>> const T *data; >>> int length; >>> >>> class_zoo (nonetype) : data (nullptr), length (0) {} >>> class_zoo (const T &e) : data (&e), length (1) {} >> >> Capturing a const referece via a pointer is error-prone as for >> example literal constants class_zoo<const int *> zoo(0) >> have associated objects that live only throughout the function >> call. > Thanks for confirming this. But do you imply capturing a non-const > reference via a pointer is safe, which I would assume it unsafe > either?
Well, "more" safe at least ;) Richard. > - Joey >> >> So clearly your testcase is invalid. >> >> Richard.