This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ask for help


Wei, Wanxia wrote:

> My C program is a local search algorithm for solving SAT (Satisfiability problem). The
> following is a brief description of this program. 
> 
> This program uses random integers to generate an initial assignment to a SAT instance.
> Then, it chooses a variable by using a heuristic and then flips this variable (flip
> means to change the value of a variable from 0 to 1 or from 1 to 0) in each search
> step. After many search steps, if the assignment satisfies the instance, this program
> stops. If the assignment still does not satisfy the instance after many search steps,
> this program stops after a predefined number of search steps. The number of search
> steps is what I call performance in my previous e-mail. In addition, this program uses
> both static and dynamic allocations. 
> 
> When I ran the two executables with different options on some SAT instances, they have
> different flip numbers (the parameters for these two executables are the same. For
> example, I use the same seed for them to generate initial assignments).  I ran the
> executable generated by using âgcc -m32 âO3 âlmâ on a wide range of instance on
> different servers for more than 1 year but I never got any errors (such as core dump).

Well, this is hard.  If your program behaves differently when
-fno-strict-aliasing is used then it's very likely that, yes, your
program has a bug.  But for me to explain what -fno-strict-aliasing
does requires you to have a fairly good understanding of the C
language. There's a fairly good explanation at
http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html

In summary,

"Dereferencing a cast of a variable from one type of pointer to a different type is
_usually_ in violation of the strict aliasing rule."

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]