In compiling my software to use LLVM, I have noticed many occurrences of C style casting in LLVM header files. Since I compile with the -Wold-style-cast flag to g++, I get warnings about each of them. This isn't a big deal but I try to keep my code compilations both error and warning free (makes spotting true errors easier). I'm wondering why a new C++ (LLVM) would choose to use C style casting? Wouldn't it be safer/clearer to use C++ style casting? These occur pretty much only in Support/Casting.h and llvm/Use.h. They may occur elsewhere but these are the only ones I've found so far. A case in point: /proj/work/llvm/include/Support/Casting.h: In static member function `static typename llvm::cast_retty<To, From>::ret_type llvm::cast_convert_val<To, FromTy, FromTy>::doit(const FromTy&)': /proj/work/llvm/include/Support/Casting.h:181: warning: use of old-style cast The offending code looks like: template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> { // This _is_ a simple type, just cast it. static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) { return (typename cast_retty<To, FromTy>::ret_type)Val; } }; Shouldn't the return statement look like: return static_cast<typename cast_retty<To, FromTy>::ret_type>(Val); ? Just curious ... Sorry if this is an old issue ... Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20031115/030ee9b0/attachment.sig>
On Sat, 15 Nov 2003, Reid Spencer wrote:> In compiling my software to use LLVM, I have noticed many occurrences of > C style casting in LLVM header files. Since I compile with the > -Wold-style-cast flag to g++, I get warnings about each of them. This > isn't a big deal but I try to keep my code compilations both error > and warning free (makes spotting true errors easier).Ah, ok, we never have used that flag. :)> I'm wondering why a new C++ (LLVM) would choose to use C style casting? > Wouldn't it be safer/clearer to use C++ style casting?Force of habit I gues...> These occur pretty much only in Support/Casting.h and llvm/Use.h. They > may occur elsewhere but these are the only ones I've found so far.I have no problem with fixing this, though I would prefer to do it incrementally as opposed to a monster patch. If you want to prepare a patch for just the header files, I would have no problem with it... -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Consider it done. I really only care about the header files anyway :) Reid On Sat, 2003-11-15 at 16:11, Chris Lattner wrote:> On Sat, 15 Nov 2003, Reid Spencer wrote: > > > In compiling my software to use LLVM, I have noticed many occurrences of > > C style casting in LLVM header files. Since I compile with the > > -Wold-style-cast flag to g++, I get warnings about each of them. This > > isn't a big deal but I try to keep my code compilations both error > > and warning free (makes spotting true errors easier). > > Ah, ok, we never have used that flag. :) > > > I'm wondering why a new C++ (LLVM) would choose to use C style casting? > > Wouldn't it be safer/clearer to use C++ style casting? > > Force of habit I gues... > > > These occur pretty much only in Support/Casting.h and llvm/Use.h. They > > may occur elsewhere but these are the only ones I've found so far. > > I have no problem with fixing this, though I would prefer to do it > incrementally as opposed to a monster patch. If you want to prepare > a patch for just the header files, I would have no problem with it... > > -Chris-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20031115/39c63c7f/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20031115/39c63c7f/attachment.sig>