EmbDev.net

Forum: ARM programming with GCC/GNU tools Please test this code with the latest GNU tools

Author: A. S. (aleksazr)
Posted on:

Since I don't have fast access to the web (all the time),
please test this on your system. Thank you

I currently use: "arm-elf-gcc (GCC) 4.1.1 (WinARM)"
and I get this error:
source.c:18: warning: will never be executed

(the loop: line)

You can read more on this here:
http://groups.google.com/group/comp.lang.c.moderat...
// Removes identical (and consecutive) points
// Out: new file size, in bytes

typedef signed int SINT;
typedef SINT* PSINT;

#define Xflag   (-1)
#define FileEnd   0

SINT RemoveDups (PSINT pFile)
{
    PSINT src, dst;
    SINT x,y;

        src = pFile;
        dst = pFile;

loop:
//  while (1) {

    // read XY from src and advance src
        x = *src++;
        y = *src++;

    // write XY to dst and advance dst
        *dst++ = x;
        *dst++ = y;

    // end reached? return new size
        if ( (x == Xflag) && (y == FileEnd) )
            return ((SINT) dst - (SINT) pFile);

    // skip point, if two adjacent points are equal
        if ( (x == *src) && (y == *(src+1)) )
            src += 2;
//  }
        goto loop;
}
Author: kbuchegg@gmx.at (Guest)
Posted on:

It would be easier, if you could tell us, which line this warning refers
to.
Author: Thomas Pircher (tpircher)
Posted on:

How do you compile?

I don't have any arm-gcc at hand right now, but I tried v3.4.4 and
v4.2.2 of GCC and I can't get that warning. I compile with
gcc -W -Wall -pedantic -std=c99 -c test.c

Also, from a logical point of view, I don't see why a line containing a
label only(!) could ever generate a warning "will never be executed".

I guess you have some other problems in your code as well, such as the
fact that you are reading the data from the memory and write it back to
exactly the same position. (Apart from the other things people advised
you in the comp.lang.c.moderated group.)

I'm afraid nobody will be able to help you unless you post a minimal
complete program that enables us to reproduce your problem.

Cheers
Thomas
Author: Karl heinz Buchegger (kbuchegg) (Moderator)
Posted on:

Thomas Pircher wrote:

> I guess you have some other problems in your code as well, such as the
> fact that you are reading the data from the memory and write it back to
> exactly the same position. (Apart from the other things people advised
> you in the comp.lang.c.moderated group.)

Well.
They did not realize the intention of this code (and I really wonder how
this is possible in this group. The guys there are pretty clever)
It is true, that in the beginning the same data is stored back from
where it was read. But that will change throughout the looping, since
src can perform additional increments throughout the looping.

> I'm afraid nobody will be able to help you unless you post a minimal
> complete program that enables us to reproduce your problem.

That's true.
Author: A. S. (aleksazr)
Posted on:

> It would be easier, if you could tell us, which line this warning refers
> to.

I did tell, line 18 (the loop: line)

> How do you compile?

Sorry... I took your command line and added
"-Wunreachable-code -O3" so it looks like this:
arm-elf-gcc -W -Wall -pedantic -std=c99 -c -Wunreachable-code -O3
source.c

and that gives me
source.c: In function 'RemoveDups':
source.c:18: warning: will never be executed

> I'm afraid nobody will be able to help you unless you post a minimal
> complete program that enables us to reproduce your problem.

The source I gave IS all there is.
(I just forgot to show the compile line)

Cheers
Author: Cas (Guest)
Posted on:

I don't know much about gcc compiler however it is obvious by the fact
you are adding -Wunreachable-code argument is producing that output and
this easily answerable by reading the man page for gcc and a quick
google search:

http://linux.die.net/man/1/gcc

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

The last comment is the most important "-Wunreachable-code has been
removed." is the most pertinent.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]






webmaster@embdev.netContactAdvertising on EmbDev.net