This is the mail archive of the gcc-bugs@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]

c/3440: pointer to a struct changes when no assignment has been made to it



>Number:         3440
>Category:       c
>Synopsis:       pointer to a struct changes when no assignment has been made to it
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 27 08:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Andy Wingo
>Release:        gcc version 2.95.4 20010604 (Debian prerelease)
>Organization:
>Environment:
Debian GNU/Linux unstable, updated last night (6/27)
>Description:
the 'd' pointer changes when the LADSPA_IS_PORT_INPUT macro is called. Here is the cpp'd code:

static gboolean
has_inp_out (const LADSPA_Descriptor *d, gint inp, gint out)
{
    gint inp_count, out_count, i;
    
    inp_count = 0;
    out_count = 0;
    
    for (i=0; i < d->PortCount; i++) {
        if ((( d->PortDescriptors[i] ) & 0x1 )  &&
            (( d->PortDescriptors[i] ) & 0x8 ) )
            inp_count++;
        if ((( d->PortDescriptors[i] ) & 0x2 )  &&
            (( d->PortDescriptors[i] ) & 0x8 ) )
            out_count++;
    }

    if (inp_count==inp && out_count==out)
        return TRUE;
    else
        return FALSE;
}

Right in the first if, d changes to be equal to d->PortDescriptors. I've debugged this and it is repeatable. Here is the assembler that gets produced:

Dump of assembler code for function has_inp_out:
0x80557ec <has_inp_out>:        push   %ebp
0x80557ed <has_inp_out+1>:      mov    %esp,%ebp
0x80557ef <has_inp_out+3>:      sub    $0xc,%esp
0x80557f2 <has_inp_out+6>:      push   %edi
0x80557f3 <has_inp_out+7>:      push   %esi
0x80557f4 <has_inp_out+8>:      push   %ebx
0x80557f5 <has_inp_out+9>:      mov    0x8(%ebp),%edx
0x80557f8 <has_inp_out+12>:     xor    %esi,%esi
0x80557fa <has_inp_out+14>:     xor    %ebx,%ebx
0x80557fc <has_inp_out+16>:     xor    %ecx,%ecx
0x80557fe <has_inp_out+18>:     mov    0x18(%edx),%eax
0x8055801 <has_inp_out+21>:     cmp    %eax,%ebx
0x8055803 <has_inp_out+23>:     jae    0x805582f <has_inp_out+67>
0x8055805 <has_inp_out+25>:     mov    0x1c(%edx),%edx
0x8055808 <has_inp_out+28>:     mov    %edx,0xfffffffc(%ebp)
0x805580b <has_inp_out+31>:     mov    %eax,%edi
0x805580d <has_inp_out+33>:     lea    0x0(%esi),%esi
0x8055810 <has_inp_out+36>:     mov    0xfffffffc(%ebp),%eax
0x8055813 <has_inp_out+39>:     mov    (%eax,%ecx,4),%edx
0x8055816 <has_inp_out+42>:     mov    %edx,%eax
0x8055818 <has_inp_out+44>:     and    $0x9,%eax
0x805581b <has_inp_out+47>:     cmp    $0x9,%eax
0x805581e <has_inp_out+50>:     jne    0x8055821 <has_inp_out+53>
0x8055820 <has_inp_out+52>:     inc    %esi
0x8055821 <has_inp_out+53>:     and    $0xa,%edx
0x8055824 <has_inp_out+56>:     cmp    $0xa,%edx
0x8055827 <has_inp_out+59>:     jne    0x805582a <has_inp_out+62>
0x8055829 <has_inp_out+61>:     inc    %ebx
0x805582a <has_inp_out+62>:     inc    %ecx
0x805582b <has_inp_out+63>:     cmp    %edi,%ecx
0x805582d <has_inp_out+65>:     jb     0x8055810 <has_inp_out+36>
0x805582f <has_inp_out+67>:     cmp    0xc(%ebp),%esi
0x8055832 <has_inp_out+70>:     jne    0x8055840 <has_inp_out+84>
0x8055834 <has_inp_out+72>:     cmp    0x10(%ebp),%ebx
0x8055837 <has_inp_out+75>:     jne    0x8055840 <has_inp_out+84>
0x8055839 <has_inp_out+77>:     mov    $0x1,%eax
0x805583e <has_inp_out+82>:     jmp    0x8055842 <has_inp_out+86>
0x8055840 <has_inp_out+84>:     xor    %eax,%eax
0x8055842 <has_inp_out+86>:     pop    %ebx
0x8055843 <has_inp_out+87>:     pop    %esi
0x8055844 <has_inp_out+88>:     pop    %edi
0x8055845 <has_inp_out+89>:     leave  
---Type <return> to continue, or q <return> to quit---
0x8055846 <has_inp_out+90>:     ret    
End of assembler dump.
>How-To-Repeat:

>Fix:
I'm no good with assembler.
>Release-Note:
>Audit-Trail:
>Unformatted:


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