On Sep 24, 2007, at 3:15 PM, Dale Johannesen wrote:> > On Sep 24, 2007, at 3:07 PM, Bill Wendling wrote: > >> A debug or release build? >> >> -bw > > Both, actually.Weird. I see a potential problem, though. The code is like this: void dumpToDOUT(SparseBitVector<> *bitmap) { dump(*bitmap, DOUT); } where dump expects an llvm::OStream& for the second argument. However, when NDEBUG is #defined, DOUT is "llvm::OStream(0)", so it can't be passed by reference. -bw
On 9/24/07, Bill Wendling <isanbard at gmail.com> wrote:> On Sep 24, 2007, at 3:15 PM, Dale Johannesen wrote: > > > > > On Sep 24, 2007, at 3:07 PM, Bill Wendling wrote: > > > >> A debug or release build? > >> > >> -bw > > > > Both, actually. > > Weird. I see a potential problem, though. The code is like this: > > void dumpToDOUT(SparseBitVector<> *bitmap) { > dump(*bitmap, DOUT); > } > > where dump expects an llvm::OStream& for the second argument. > However, when NDEBUG is #defined, DOUT is "llvm::OStream(0)", so it > can't be passed by reference.What compiler are you compiling with? I build release and debug builds on darwin (and run the testsuite) before i check in my changes :). You can feel free to remove the function, it is simply a GDB helper :)
On 9/25/07, Daniel Berlin <dberlin at dberlin.org> wrote:> On 9/24/07, Bill Wendling <isanbard at gmail.com> wrote: > > On Sep 24, 2007, at 3:15 PM, Dale Johannesen wrote: > > > > Weird. I see a potential problem, though. The code is like this: > > > > void dumpToDOUT(SparseBitVector<> *bitmap) { > > dump(*bitmap, DOUT); > > } > > > > where dump expects an llvm::OStream& for the second argument. > > However, when NDEBUG is #defined, DOUT is "llvm::OStream(0)", so it > > can't be passed by reference. > What compiler are you compiling with? > I build release and debug builds on darwin (and run the testsuite) > before i check in my changes :). >I'm just using GCC, though it's on Leopard. I'm not sure if they have a fix to catch this type of code.> You can feel free to remove the function, it is simply a GDB helper :) >I just put it inside #ifdef's, so it now works. :-) -bw
On Monday 24 September 2007 17:23, Bill Wendling wrote:> Weird. I see a potential problem, though. The code is like this: > > void dumpToDOUT(SparseBitVector<> *bitmap) { > dump(*bitmap, DOUT); > } > > where dump expects an llvm::OStream& for the second argument. > However, when NDEBUG is #defined, DOUT is "llvm::OStream(0)", so it > can't be passed by reference.We ran into a similar problem in our custom code here. To work around it I modified Debug.h like this: #ifdef NDEBUG static llvm::OStream NullStream(0); #define DOUT llvm::NullStream #else #define DOUT llvm::getErrorOutputStream(DEBUG_TYPE) #endif -Dave
Hi Dave,> We ran into a similar problem in our custom code here. To work around > it I modified Debug.h like this: > > #ifdef NDEBUG > static llvm::OStream NullStream(0); > #define DOUT llvm::NullStream > #else > #define DOUT llvm::getErrorOutputStream(DEBUG_TYPE) > #endif >I thought about doing this, but there's the potential for naming conflicts that won't be caught until a release build is done. :-( I wonder, though. Would it make sense to put the stream decls in their own namespace (say "namespace stream")? That way we could prevent naming conflicts and also this bad "gotcha"... -bw