Luo, Xionghu via llvm-dev
2016-May-11 06:07 UTC
[llvm-dev] Non-void function does not return value
Hi Chandler, I scanned the LLVM source code, and found some potential code issues, take the piece of code in file './include/llvm/Support/Allocator.h' for example: 80 /// \brief Deallocate space for a sequence of objects without constructing them. 81 template <typename T> 82 typename std::enable_if< 83 !std::is_same<typename std::remove_cv<T>::type, void>::value, void>::type 84 [https://otckw.jf.intel.com:8080/review/review/images/folding/collapse_top.png] Deallocate(T *Ptr, size_t Num = 1) { 85 Deallocate(static_cast<const void *>(Ptr), Num * sizeof(T)); 86 [https://otckw.jf.intel.com:8080/review/review/images/folding/collapse_bottom.png] } If the typename T is void, the std::is_same will be FALSE, which means the std::enable_if::type is UNDEFIED. So do you think it need a fix? Thanks. Luo Xionghu Best Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160511/9f5c7393/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.png Type: image/png Size: 478 bytes Desc: image005.png URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160511/9f5c7393/attachment.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: image006.png Type: image/png Size: 476 bytes Desc: image006.png URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160511/9f5c7393/attachment-0001.png>
Sean Silva via llvm-dev
2016-May-11 06:18 UTC
[llvm-dev] Non-void function does not return value
I think this is the intended use of enable_if, no? http://en.cppreference.com/w/cpp/types/enable_if "This metafunction is a convenient way to leverage SFINAE to conditionally remove functions from overload resolution based on type traits and to provide separate function overloads and specializations for different type traits" -- Sean Silva On Tue, May 10, 2016 at 11:07 PM, Luo, Xionghu via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi Chandler, > > I scanned the LLVM source code, and found some potential code issues, take > the piece of code in file ‘./include/llvm/Support/Allocator.h’ for example: > > > > > > 80 > > /// \brief Deallocate space for a sequence of objects without > constructing them. > > 81 > > *template* <*typename* T> > > 82 > > *typename* std::enable_if< > > 83 > > !std::is_same<*typename* std::remove_cv<T>::type, *void*>::value, > *void*>::type > > 84 > > [image: > https://otckw.jf.intel.com:8080/review/review/images/folding/collapse_top.png] > > Deallocate(T *Ptr, size_t Num = 1) { > > 85 > > Deallocate(*static_cast*<*const* *void* *>(Ptr), Num * *sizeof*(T)); > > 86 > > [image: > https://otckw.jf.intel.com:8080/review/review/images/folding/collapse_bottom.png] > > } > > > > > > If the typename T is void, the std::is_same will be FALSE, which means the > std::enable_if::type is UNDEFIED. > > So do you think it need a fix? > > Thanks. > > > > > > Luo Xionghu > > Best Regards > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160510/d311467b/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.png Type: image/png Size: 478 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160510/d311467b/attachment.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: image006.png Type: image/png Size: 476 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160510/d311467b/attachment-0001.png>