linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* possible egcs c compiler bug
@ 1999-05-19 20:19 Thomas C. Allison
  1999-05-19 20:56 ` Brad Boyer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas C. Allison @ 1999-05-19 20:19 UTC (permalink / raw)
  To: linuxppc-user; +Cc: linuxppc-dev


I have found what *appears* to be a bug in the C compiler.  I have experienced
this bug in R4 (regardless of the compiler/library installed) as well as in
the latest (i.e. all the latest packages through 5/15/1999) pre-R5
installation.  I include a short program below which illustrates the problem
I am having.  The code compiles without error on my i386 machine
running RHL 5.2.  The version of EGCS on the PC is 1.0.3 versus 1.1.2 on my
PowerMac, so I don't know if this is a PPC problem or an EGCS problem.
Any input is greatly appreciated.

The code is as follows:

test.c:

     #include <stdio.h>
     #include <stdarg.h>

     static int myFunction(va_list inList)
     {
        va_list newList;
        newList = inList;
     }

When I try to compile the code

     % gcc -c test.c

I get the following error message

     test.c: In function `myFunction':
     test.c:7: incompatible types in assignment

Any ideas?

Thanks in advance,

Tom

+------------------------------------------------------------------------------+
| Dr. Thomas C. Allison                          | thomas.allison@nist.gov     |
| Computational Chemistry Group                  | (301)975-2216 (voice)       |
| National Institute of Standards and Technology | (301)869-4020 (fax)         |
| 100 Bureau Drive, Stop 8380                    |                             |
| Gaithersburg, Maryland 20899-8380              |                             |
+------------------------------------------------------------------------------+
  Chemistry is applied theology.  --- Augustus Stanley Owsley III

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: possible egcs c compiler bug
  1999-05-19 20:19 possible egcs c compiler bug Thomas C. Allison
@ 1999-05-19 20:56 ` Brad Boyer
  1999-05-19 21:04 ` Hartmut Koptein
  1999-05-19 21:26 ` Franz Sirl
  2 siblings, 0 replies; 4+ messages in thread
From: Brad Boyer @ 1999-05-19 20:56 UTC (permalink / raw)
  To: Thomas C. Allison; +Cc: linuxppc-user, linuxppc-dev


> I have found what *appears* to be a bug in the C compiler.  I have experienced
> this bug in R4 (regardless of the compiler/library installed) as well as in
> the latest (i.e. all the latest packages through 5/15/1999) pre-R5
> installation.  I include a short program below which illustrates the problem
> I am having.  The code compiles without error on my i386 machine
> running RHL 5.2.  The version of EGCS on the PC is 1.0.3 versus 1.1.2 on my
> PowerMac, so I don't know if this is a PPC problem or an EGCS problem.
> Any input is greatly appreciated.

"It's not a bug, it's a feature"...

You're using something that is not technically the proper way to use
va_list in your code.  However, that code works on everything but ppc.
It has to do with the way va_list is implemented on any ppc platform,
and causes all sorts of strange things to happen when you don't follow
the spec close enough.  Find a better way to copy the va_list.  Just
using the = operator isn't enough on ppc.  Use a block copy of
sizeof(va_list) bytes, or some such.  This has come up before, so if
you search the list archives, you should find sample code.  Someone
else could give a lot more details on this.  I only know the general
overview.

      Brad Boyer
      flar@cegt201.bradley.edu

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: possible egcs c compiler bug
  1999-05-19 20:19 possible egcs c compiler bug Thomas C. Allison
  1999-05-19 20:56 ` Brad Boyer
@ 1999-05-19 21:04 ` Hartmut Koptein
  1999-05-19 21:26 ` Franz Sirl
  2 siblings, 0 replies; 4+ messages in thread
From: Hartmut Koptein @ 1999-05-19 21:04 UTC (permalink / raw)
  To: Thomas C. Allison; +Cc: linuxppc-user, linuxppc-dev


> I have found what *appears* to be a bug in the C compiler.  I have experienced
> this bug in R4 (regardless of the compiler/library installed) as well as in
> the latest (i.e. all the latest packages through 5/15/1999) pre-R5
> installation.  I include a short program below which illustrates the problem
> I am having.  The code compiles without error on my i386 machine
> running RHL 5.2.  The version of EGCS on the PC is 1.0.3 versus 1.1.2 on my
> PowerMac, so I don't know if this is a PPC problem or an EGCS problem.
> Any input is greatly appreciated.
> 
> The code is as follows:
> 
> test.c:
> 
>      #include <stdio.h>
>      #include <stdarg.h>
> 
>      static int myFunction(va_list inList)
>      {
>         va_list newList;
>         newList = inList;
>      }


Try this:

      #include <stdio.h>
      #include <stdarg.h>

      static int myFunction(va_list inList)
      {
         va_list newList;
         
	 __va_copy(newList, inList);
      }




-- 
 Dipl.-Ing. (FH) Hartmut Koptein                       EMail:
 Friedrich-van-Senden-Str. 7                           
 26603 Aurich   
 Tel.: +49-4941-10390                                  koptein@debian.org

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: possible egcs c compiler bug
  1999-05-19 20:19 possible egcs c compiler bug Thomas C. Allison
  1999-05-19 20:56 ` Brad Boyer
  1999-05-19 21:04 ` Hartmut Koptein
@ 1999-05-19 21:26 ` Franz Sirl
  2 siblings, 0 replies; 4+ messages in thread
From: Franz Sirl @ 1999-05-19 21:26 UTC (permalink / raw)
  To: linuxppc-dev, Thomas C. Allison, linuxppc-user


Am Wed, 19 May 1999 schrieb Thomas C. Allison:
>I have found what *appears* to be a bug in the C compiler.  I have experienced
>this bug in R4 (regardless of the compiler/library installed) as well as in
>the latest (i.e. all the latest packages through 5/15/1999) pre-R5
>installation.  I include a short program below which illustrates the problem
>I am having.  The code compiles without error on my i386 machine
>running RHL 5.2.  The version of EGCS on the PC is 1.0.3 versus 1.1.2 on my
>PowerMac, so I don't know if this is a PPC problem or an EGCS problem.
>Any input is greatly appreciated.
>
>The code is as follows:
>
>test.c:
>
>     #include <stdio.h>
>     #include <stdarg.h>
>
>     static int myFunction(va_list inList)
>     {
>        va_list newList;
>        newList = inList;
>     }
>
>When I try to compile the code
>
>     % gcc -c test.c
>
>I get the following error message
>
>     test.c: In function `myFunction':
>     test.c:7: incompatible types in assignment
>
>Any ideas?

That is simply unportable code. va_list maybe of any underlying type, and is in
this case an array. If you want portable code, use:

     static int myFunction(va_list inList)
     {
        va_list newList;
        __va_copy(newList, inList);
     }

If you use varargs extensively in your application, I strongly recommend you to
use egcs-*1.1.2-12c or later on DRR1/preR5, which fixes some annoying bugs
in the ppc-linux varargs handling.

Franz.

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-05-19 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-05-19 20:19 possible egcs c compiler bug Thomas C. Allison
1999-05-19 20:56 ` Brad Boyer
1999-05-19 21:04 ` Hartmut Koptein
1999-05-19 21:26 ` Franz Sirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).