On Tue, 3 Jan 2012 11:45:21 -0800 (PST), Monkey wrote:
> -O3 causes a segfault on Linux in the same place - I wonder if it has
> something do with optimising out some instructions which don't appear
> to be used. In the mask section I make use of int* and float* pointing
> to the same address, and it seemed to be around this point that
> multiblend was failing. -O2, though, seems okay on Linux.

This sounds like a pointer aliasing problem.  See the man page for gcc:

       -fstrict-aliasing
           Allow the compiler to assume the strictest aliasing rules
           applicable to the language being compiled.  For C (and C++), this
           activates optimizations based on the type of expressions.  In
           particular, an object of one type is assumed never to reside at the
           same address as an object of a different type, unless the types are
           almost the same.  For example, an "unsigned int" can alias an
           "int", but not a "void*" or a "double".  A character type may alias
           any other type.

           Pay special attention to code like this:

                   union a_union {
                     int i;
                     double d;
                   };

                   int f() {
                     union a_union t;
                     t.d = 3.0;
                     return t.i;
                   }

           The practice of reading from a different union member than the one
           most recently written to (called "type-punning") is common.  Even
           with -fstrict-aliasing, type-punning is allowed, provided the
           memory is accessed through the union type.  So, the code above will
           work as expected.    However, this code might not:

                   int f() {
                     union a_union t;
                     int* ip;
                     t.d = 3.0;
                     ip = &t.i;
                     return *ip;
                   }

           Similarly, access by taking the address, casting the resulting
           pointer and dereferencing the result has undefined behavior, even
           if the cast uses a union type, e.g.:

                   int f() {
                     double d = 3.0;
                     return ((union a_union *) &d)->i;
                   }

           The -fstrict-aliasing option is enabled at levels -O2, -O3, -Os.


-- 
Robert Krawitz                                     <[email protected]>

Tall Clubs International  --  http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom  --  http://ProgFree.org
Project lead for Gutenprint   --    http://gimp-print.sourceforge.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton

-- 
You received this message because you are subscribed to the Google Groups 
"Hugin and other free panoramic software" group.
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/hugin-ptx

Reply via email to