This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
> On Fri, Sep 26, 2003 at 01:49:23PM +0200, David Brown wrote: > > I've filled out a complete example below. The "-Wunreachable-code" is not > > included in the -Wall flags, so it has to be specified seperately. > > Indeed. I don't actually have it at all on my gcc. > > > >m68k-elf-gcc -W -O2 -c test.c -o test.o -Wunreachable-code > > test.c: In function `test1': > > test.c:13: warning: will never be executed > > This one should actually always turn up (unsigned can't be < 0 ) > Yes, that function is for testing the opposite case. I suppose it is also an issue that it does not turn up until using -O2 optomisation, but that's a matter of the compiler only running the more advanced code-flow analysis passes when doing more optomisation. I can't expect the compiler to be able to catch *all* unreachable code! Incidently, on my first try at that test case (using "(u >= 0)" ), the compiler always spotting the unnecessary comparison. > > // ******************************* > > extern void sendString(char *p); > > extern void sendNewline(void); > > Can we also get those 2 functions? Ideally you want to > reduce the test case to one small file, the gcc people will > appreciate that if it turns out to be a bug. > I don't think it would help at all, and to give you the full code would mean you'd also need all my uart handling code, circular buffer code, interrupt routines, hardware configuration, .... The code is just artificial test code, and these functions are merely a break from the usual foo() and bar(), and could happily be stubbed out. An alternative would be to set some volatile variables (I like volatiles for this sort of thing - it stops the optomiser being too helpful :-) // ******************************* volatile int vola; volatile int volb; void test1(unsigned int u) { if (u > 0) { vola = 1; } else if (u == 0) { vola = 2; } else { vola = 3; }; } void test2(int i) { switch (i) { case 0 : vola = 0; volb = 1; break; case 1 : vola = 1; volb = 1; break; case 2 : vola = 2; volb = 1; break; } } // ******************************* ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |