------- Additional Comments From tsv at solvo dot ru  2005-07-12 23:16 -------
(In reply to comment #5)
> (In reply to comment #4)
> 
> > Unfortunatelly, with switching to gcc 4.x some code started to
> > produce such exceptions (with gcc 3.4 everything was fine). Is there
> > an option to make gcc think that passed *variable is char * and
> > can't be null pointer?
> 
> No, sorry. -fno-strict-aliasing doesn't cover this.
> 
> > Why the simpe test case (that contains the same function and a
> > function that calls it) produces the correct code (I could attach it
> > if you have time to take a look at it).
> 
> Well, for this:
> 
> void f(long *p) {
>     *(char *) p = 0;
> }
> 
> I get
> 
>         ldl     t0,0(a0)
>         andnot  t0,0xff,t0
>         stl     t0,0(a0)
> 
> which will fail with unaligned *p, with all gccs I have till back to
> 2.95. So this doesn't seem to be anything recent...
> 

For this one:

typedef char * gptr;
typedef char my_bool;
//typedef void * gtpr;

static void foo(int sv, gptr var, long value)
{
   switch(sv)
     {
      case 2:
        *((my_bool*) var) = (my_bool) value;
        break;
      case 3:
        *((int *) var) = (int) value;
        break;

      case 4:
        *((long *) var) = (long) value;
        break;

      case 5:
        *((long long *) var) = (long long) value;
        break;
      case 6:
        *((unsigned int *) var) = (unsigned int) value;
        break;
      case 7:
        *((unsigned long *) var) = (unsigned long) value;
        break;
      case 8:
        *((unsigned long long *) var) = (unsigned long long) value;
        break;
      default:
        ;
     }

}

void foo1(int a, gptr ad, long v)
{
   foo(a, ad, v);
}

I get :

$L3:
        insbl $18,$17,$2
        ldq_u $1,0($17)
        mskbl $1,$17,$1
        bis $2,$1,$2
        stq_u $2,0($17)
        ret $31,($26),1
        .end foo1
        .ident  "GCC: (GNU) 4.0.0 20050519 (Red Hat 4.0.0-8)"
        .section        .note.GNU-stack,"",@progbits

I am just trying to understand how to modify original code (part of MySQL) to
get work without exceptions.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22447

Reply via email to