Please test this code with the latest GNU tools

OP #1592180
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
}
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
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.
OP
> 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

Reply

A question of your own? This thread is over 16 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.