ProxyJNI.cpp does not build with recent GCC snapshots

VERIFIED DUPLICATE of bug 39050

Status

P3
critical
VERIFIED DUPLICATE of bug 39050
19 years ago
8 years ago

People

(Reporter: green, Assigned: blackconnect)

Tracking

Trunk
x86
Linux

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

19 years ago
ProxyJNI.cpp does not build with recent snapshots of GCC.
This has to do with how va_args is being used.
It's not very nice, but here's a patch.


Index: ProxyJNI.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/oji/src/ProxyJNI.cpp,v
retrieving revision 1.15
diff -u -r1.15 ProxyJNI.cpp
--- ProxyJNI.cpp        2000/01/05 01:41:06     1.15
+++ ProxyJNI.cpp        2000/04/27 04:16:25
@@ -182,17 +182,19 @@
                     		case jobject_type:
					jargs[i].l = va_arg(args, jobject);
					break;
+                               // These next four types are promoted to `int'
when
+                               // passed through `...'.
				case jboolean_type:
-                                       jargs[i].z = va_arg(args, jboolean);
+                                       jargs[i].z = va_arg(args, int);
					break;
				case jbyte_type:
-                                       jargs[i].b = va_arg(args, jbyte);
+                                       jargs[i].b = va_arg(args, int);
					break;
				case jchar_type:
-                                       jargs[i].b = va_arg(args, jbyte);
+                                       jargs[i].b = va_arg(args, int);
					break;
				case jshort_type:
-                                       jargs[i].s = va_arg(args, jshort);
+                                       jargs[i].s = va_arg(args, int);
					break;
				case jint_type:
					jargs[i].i = va_arg(args, jint);
@@ -200,8 +202,10 @@
                    		case jlong_type:
					jargs[i].j = va_arg(args, jlong);
					break;
+                               // `jfloat's are promoted to `double' when
passed
+                               // through `...'.
				case jfloat_type:
-                                       jargs[i].f = va_arg(args, jfloat);
+                                       jargs[i].f = va_arg(args, double);
					break;
				case jdouble_type:
					jargs[i].d = va_arg(args, jdouble);
(Assignee)

Comment 1

19 years ago
I was not able to reproduce this bug on solaris 2.6
using gcc2.95.2 and gcc 2.96 20000427 

I can reproduce it on linux using gcc 2.96 20000428 
(I got gcc from anoncvs.cygnus.com)

I'v found this comment in lib/gcc-lib/i686-pc-linux-gnu/2.96/include/stdarg.h
--
/* Note that the type used in va_arg is supposed to match the
   actual type **after default promotions**.
   Thus, va_arg (..., short) is not valid.  */
--

I am not sure I understand what is "actual type" and what is "default
promotions"

I am getting this bug.
Status: UNCONFIRMED → NEW
Ever confirmed: true
(Assignee)

Comment 2

19 years ago
I am gonna handle this bug.
Assignee: drapeau → idk
(Assignee)

Comment 3

19 years ago
Hi,

why do you think that this is mozilla bug?
Is not it gcc bug?



(Reporter)

Comment 4

19 years ago
comp.lang.c faq:

15.10: I have a varargs function which accepts a float parameter.  Why isn't
  
   va_arg(argp, float)
  
working?

In the variable-length part of variable-length argument lists, the old
"default argument promotions" apply: arguments of type float are
always promoted (widened) to type double, and types char and short int
are promoted to int.  Therefore, it is never correct to invoke
va_arg(argp, float); instead you should always use va_arg(argp,
double).  Similarly, use va_arg(argp, int) to retrieve arguments which
were originally char, short, or int.  (For analogous reasons, the last
"fixed" argument, as handed to va_start(), should not be widenable.)
See also questions 11.3 and 15.2.
  
 References: ANSI Sec. 3.3.2.2; ISO Sec. 6.3.2.2; Rationale
 Sec. 4.8.1.2; H&S Sec. 11.4 p. 297.



I should add that my proposed patch is only valid for 32-bit systems.
You'll also have to deal with jint on 64-bit systems.
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 5

19 years ago
*** Bug 40937 has been marked as a duplicate of this bug. ***
(Assignee)

Comment 6

18 years ago

*** This bug has been marked as a duplicate of 39050 ***
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → DUPLICATE

Updated

18 years ago
Status: RESOLVED → VERIFIED

Comment 7

18 years ago
Verified

Updated

8 years ago
Component: Java: OJI → Java: OJI
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.