EmbDev.net

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


von A. S. (aleksazr)


Rate this post
useful
not useful
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.moderated/browse_thread/thread/71d51a56be7cb29d
1
// Removes identical (and consecutive) points
2
// Out: new file size, in bytes
3
4
typedef signed int SINT;
5
typedef SINT* PSINT;
6
7
#define Xflag   (-1)
8
#define FileEnd   0
9
10
SINT RemoveDups (PSINT pFile)
11
{
12
    PSINT src, dst;
13
    SINT x,y;
14
15
        src = pFile;
16
        dst = pFile;
17
18
loop:
19
//  while (1) {
20
21
    // read XY from src and advance src
22
        x = *src++;
23
        y = *src++;
24
25
    // write XY to dst and advance dst
26
        *dst++ = x;
27
        *dst++ = y;
28
29
    // end reached? return new size
30
        if ( (x == Xflag) && (y == FileEnd) )
31
            return ((SINT) dst - (SINT) pFile);
32
33
    // skip point, if two adjacent points are equal
34
        if ( (x == *src) && (y == *(src+1)) )
35
            src += 2;
36
//  }
37
        goto loop;
38
}

von kbuchegg@gmx.at (Guest)


Rate this post
useful
not useful
It would be easier, if you could tell us, which line this warning refers 
to.

von Thomas P. (tpircher)


Rate this post
useful
not useful
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
1
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

von Karl H. (kbuchegg)


Rate this post
useful
not useful
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.

von A. S. (aleksazr)


Rate this post
useful
not useful
> 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

von Cas (Guest)


Rate this post
useful
not useful
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.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.