Closed Bug 136344 Opened 22 years ago Closed 22 years ago

SGI CC compile: void* assignment compilation problems

Categories

(NSPR :: NSPR, defect, P2)

SGI
IRIX

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sjulier, Assigned: wtc)

References

Details

Attachments

(1 file)

I have run into some (minor) problems with compiling yesterday's CVS tree (08th
April, 2002) on an SGI using CC version 7.3.1.3m under IRIX. Specifically, at
several points in the code, void* pointer values are assigned to non-void*
pointers which generates a compilation error under CC.

The compilation was configured using nsprpub/configure.

Here is a list of the errors:

==============================================================================

cc-1515 CC: ERROR File = prmem.c, Line = 170
  A value of type "void *" cannot be assigned to an entity of type "PRBool *".

      if ((sym = pr_FindSymbolInProg("nspr_use_zone_allocator")) != NULL) {

cc-1515 CC: ERROR File = prinit.c, Line = 565
  A value of type "void *" cannot be assigned to an entity of type "char *".

      attr->currentDirectory = PR_MALLOC(strlen(dir) + 1);

cc-1515 CC: ERROR File = prnetdb.c, Line = 429
  A value of type "void *" cannot be assigned to an entity of type "char *".

          tmpbuf = PR_Malloc(bufsize);

cc-1515 CC: ERROR File = prnetdb.c, Line = 561
  A value of type "void *" cannot be assigned to an entity of type "char *".

          tmpbuf = PR_Malloc(bufsize);

cc-1515 CC: ERROR File = prnetdb.c, Line = 740
  A value of type "void *" cannot be assigned to an entity of type "char *".

          tmpbuf = PR_Malloc(bufsize);

cc-1515 CC: ERROR File = prtpool.c, Line = 606
  A value of type "void *" cannot be assigned to an entity of type
          "PRThreadPool *".

        tp = PR_CALLOC(sizeof(*tp));

cc-1515 CC: ERROR File = prtrace.c, Line = 174
  A value of type "void *" cannot be assigned to an entity of type
          "PRTraceEntry *".

      tBuf = PR_Malloc( bufSize );

cc-1515 CC: ERROR File = prrwlock.c, Line = 418
  A value of type "void *" cannot be assigned to an entity of type
          "thread_rwlock_stack *".

        if ((lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key)) == NULL) {

cc-1515 CC: ERROR File = prrwlock.c, Line = 461
  A value of type "void *" cannot be assigned to an entity of type
          "thread_rwlock_stack *".

        if ((lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key)) == NULL)

cc-1515 CC: ERROR File = prrwlock.c, Line = 480
  A value of type "void *" cannot be assigned to an entity of type
          "thread_rwlock_stack *".

        lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key);

cc-1552 CC: WARNING File = prrwlock.c, Line = 97
  The variable "pr_thread_rwlock_alloc_failed" is set but never used.

  static PRUintn        pr_thread_rwlock_alloc_failed;

  A value of type "void *" cannot be assigned to an entity of type "char *".

                  rp = (void *)a->avail;

cc-1515 CC: ERROR File = plarena.c, Line = 191
  A value of type "void *" cannot be assigned to an entity of type "char *".

                  rp = (void *)a->avail;

cc-1515 CC: ERROR File = plarena.c, Line = 214
  A value of type "void *" cannot be assigned to an entity of type "char *".

              rp = (void *)a->avail;

==============================================================================

All of these can be fixed by adding the necessary casts (or, in the last three
cases, removing the void* cast).
*** Bug 136343 has been marked as a duplicate of this bug. ***
Again, please use cc NOT CC to compile c files.... this problem will go away if
you use cc as the c compiler. Ensure you have the CC and CXX env variables correct:
eg:
% setenv CC cc
% setenv CXX CC
or
$ export CC=cc
$ export CXX=CC
Here is an example:
cc -o prmem.o -c     -woff 3201 -woff 1506 -mips3 -n32 -fullwarn -xansi
-multigot -n32 -woff 1209 -mips3 -O -OPT:Olimit=4000 -g   -UNDEBUG 
-DMOZILLA_CLIENT=1 -DDEBUG=1 -DDEBUG_nickb=1 -DXP_UNIX=1 -DIRIX=1 -DSVR4=1
-D_SGI_MP_SOURCE=1 -DHAVE_FCNTL_FILE_LOCKING=1 -DIRIX6=1 -D_PR_HAVE_GETPROTO_R=1
-D_PR_HAVE_GETPROTO_R_POINTER=1 -D_PR_HAVE_SGI_PRDA_PROCMASK=1 -DHAVE_LCHOWN=1
-DHAVE_STRERROR=1 -D_PR_HAVE_GETHOST_R=1 -D_PR_HAVE_GETHOST_R_POINTER=1 
-DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM -D_NSPR_BUILD_
-I/projects/sise/mozilla/devel/workpits/moz/latest_mips/workarea/dist/include/nspr
-I../../../../../mozilla/nsprpub/pr/include
-I../../../../../mozilla/nsprpub/pr/include/private 
../../../../../mozilla/nsprpub/pr/src/malloc/prmem.c
cc WARNING:  -O conflicts with -g; changing to -O0; if you want -O, use -g3

and using CC

% CC -o prmem.o -c     -woff 3201 -woff 1506 -mips3 -n32 -fullwarn -xansi
-multigot -n32 -woff 1209 -mips3 -O -OPT:Olimit=4000 -g   -UNDEBUG 
-DMOZILLA_CLIENT=1 -DDEBUG=1 -DDEBUG_nickb=1 -DXP_UNIX=1 -DIRIX=1 -DSVR4=1
-D_SGI_MP_SOURCE=1 -DHAVE_FCNTL_FILE_LOCKING=1 -DIRIX6=1 -D_PR_HAVE_GETPROTO_R=1
-D_PR_HAVE_GETPROTO_R_POINTER=1 -D_PR_HAVE_SGI_PRDA_PROCMASK=1 -DHAVE_LCHOWN=1
-DHAVE_STRERROR=1 -D_PR_HAVE_GETHOST_R=1 -D_PR_HAVE_GETHOST_R_POINTER=1 
-DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM -D_NSPR_BUILD_
-I/projects/sise/mozilla/devel/workpits/moz/latest_mips/workarea/dist/include/nspr
-I../../../../../mozilla/nsprpub/pr/include
-I../../../../../mozilla/nsprpub/pr/include/private 
../../../../../mozilla/nsprpub/pr/src/malloc/prmem.c
CC WARNING:  -O conflicts with -g; changing to -O0; if you want -O, use -g3
cc-1515 CC: ERROR File = ../../../../../mozilla/nsprpub/pr/src/malloc/prmem.c,
Line = 170
  A value of type "void *" cannot be assigned to an entity of type "PRBool *".

      if ((sym = pr_FindSymbolInProg("nspr_use_zone_allocator")) != NULL) {
               ^

1 error detected in the compilation of
"../../../../../mozilla/nsprpub/pr/src/malloc/prmem.c".
Some people use a C++ compiler to compile their C code
because C++ accepts a "clean" subset of C and has stronger
type checking.

All the compilation errors that Mr. Julier listed are a
major difference between C and C++.  Assigning void* pointer
values to non-void* pointers is legal in C.  Adding the
necessary casts to make the C++ compilers happy is harmless
in C, so I'll be happy to do that, but it will have a
lower priority.

Note: the warning about pr_thread_rwlock_alloc_failed should
be ignored.  That variable is for debugging.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P2
Target Milestone: --- → 4.3
Version: 4.1.3 → 4.2
All of these changes are simply adding appropriate casts except for the changes

in lib/ds/plarena.c, which involve change a (void *) to a (char *) (although 
removing the cast would also work).
Comment on attachment 92487 [details] [diff] [review]
Various changes to allow compilation with CC rathen than cc

r=wtc.

Regarding the changes in lib/ds/plarena.c, you said that
they involve change a (void *) to a (char *) (although 
removing the cast would also work).  I don't see how
removing the cast would work.  The type of a->avail is
PRUword, which is unsigned long.  It requires an explicit
cast to char *.
Attachment #92487 - Flags: review+
I checked in the fix on the tip of NSPR on 2002/08/07
but forgot to mark the bug fixed.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: