[Bug c/49620] New: piece of code from modification to dvblast but cant get it to compile and run correctly

joolzg at btinternet dot com gcc-bugzilla@gcc.gnu.org
Sun Jul 3 19:43:00 GMT 2011


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

           Summary: piece of code from modification to dvblast but cant
                    get it to compile and run correctly
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: joolzg@btinternet.com


Created attachment 24664
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24664
bug report

I have a function that only works when i add another function call inbetween.

block_t *file_Read( mtime_t i_poll_timeout )
{
    i_wallclock = mdate();

    {
        block_t *p_ts, **pp_current = &p_ts;
        int i, i_len;

        if ( !i_last_packet )
        {
            switch (i_print_type) {
            case PRINT_XML:
                printf("<STATUS type=\"lock\" status=\"1\"/>\n");
                break;
            default:
                printf("frontend has acquired lock\n" );
            }
        }
        i_last_packet = i_wallclock;

        i_len = 0;
        for ( i = 0; i < i_bufsize / TS_SIZE; i++ )
        {
            *pp_current = block_New();
            i_len2 = fread( (*pp_current)->p_ts, 1, TS_SIZE, file_input);
//            msg_Warn( NULL, "read from file %s (%s) %d %p",
//                       filename, strerror(errno), i_len2, pp_current );
            if ( i_len2 < 188 )
            {
            if ( i_len2 < 188 )
            {
                msg_Err( NULL, "couldn't read from file %s (%s) %d %p",
                         filename, strerror(errno), i_len2, pp_current );
                i_len = 0;
                break;
            }
            i_len++;
            pp_current = &(*pp_current)->p_next;
        }

        pp_current = &p_ts;
        while ( i_len && *pp_current )
        {
            pp_current = &(*pp_current)->p_next;
            i_len--;
        }

        if ( *pp_current )
            msg_Dbg( NULL, "partial buffer received" );

        block_DeleteChain( *pp_current );
        *pp_current = NULL;

        return p_ts;
    }

    return NULL;
}

Now the code above DOES not work in 
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
or
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

Both machines are Ubuntu 64bit.

If the commented out msg_Warn is uncommented then the code works and we get no
error message

Ive also run it through clang and came up with no errors

joolz



More information about the Gcc-bugs mailing list