[Insight-developers] failing ITK tests when using clang, reduced test case, need C++ expert

Sean McBride sean at rogue-research.com
Mon Dec 5 14:55:18 EST 2011


Hi all,

After many man-hours, my coworker Alex and I have found why so many ITK tests fail when built with clang.

It's the ITK_NO_RETURN #define.  If it's defined to nothing, *all* tests pass with clang, it it's defined to __attribute__ ( ( noreturn ) ), then we have the problem of hundreds of crashing tests.

Any C++ language lawyers out there able to comment on whether this use of 'noreturn' is kosher?  :)  I dunno if this is an ITK or clang problem.  You may recognize the lineage of this snippit, as it is a reduction of an ITK test that started life with an itkImage and itkMultiThreader.

The bug entry (with the llvm folks) is here:
<http://llvm.org/bugs/show_bug.cgi?id=9395>

The snippit is:

----------------
#include <cassert>

// when defined, clang generates code that segfaults, gcc does not
#define NORETURN __attribute__ ( ( noreturn ) )

class A
{
protected:
  static void ThreaderCallback(void *arg) {
    A *str = (A *)arg;
    str->ThreadedGenerateData();
  }
    virtual void ThreadedGenerateData(void) NORETURN  {
    assert(0);
  }
};

class B : public A
{
protected:
  void ThreadedGenerateData() {
  }
    
public:
  void run () {
    A::ThreaderCallback(this); 
  }
};


int main() 
{
  B myb;
  myb.run();
    
  return 0;
}
----------------

Thanks!

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada




More information about the Insight-developers mailing list