From owner-freebsd-bugs Wed Apr 15 09:10:13 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA27787 for freebsd-bugs-outgoing; Wed, 15 Apr 1998 09:10:13 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA27757; Wed, 15 Apr 1998 09:10:06 -0700 (PDT) (envelope-from gnats) Received: from indigo.ie (root@ts01-07.waterford.indigo.ie [194.125.139.70]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA27294 for ; Wed, 15 Apr 1998 16:08:36 GMT (envelope-from nsmart@indigo.ie) Received: (from nsmart@localhost) by indigo.ie (8.8.8/8.8.7) id FAA05229; Fri, 1 Jan 2038 05:24:36 GMT (envelope-from nsmart) Message-Id: <203801010524.FAA05229@indigo.ie> Date: Fri, 1 Jan 2038 05:24:36 GMT From: rotel@indigo.ie Reply-To: nsmart@indigo.ie To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: misc/6310: explicit cast needed in floatpoint.h for C++ Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6310 >Category: misc >Synopsis: explicit cast needed in floatpoint.h for C++ >Confidential: yes >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 15 09:10:02 PDT 1998 >Last-Modified: >Originator: Niall Smart >Organization: >Release: FreeBSD 2.2.6-STABLE i386 >Environment: >Description: C++ does not allow implicit conversion from integer types to enum types. Although this behaviour usually "just" elicits a warning from the compiler, it may in the future it cause compilation errors. /usr/include/machine/floatingpoint.h defines the macro's fpgetround() et al as calls to either __fpgetreg or __fpsetreg. (which are defined as inline functions if __GNUC__ is defined, there does not seem to be any replacement for these functions when not using the GNU C compiler) Both of these functions return an int. The supplied patch adds appropriate casts before the calls to __fpgetreg and __fpgetreg. Also, is anyone in a position to do something about the XXX at the top of this header file? /*- * XXX the following undocumented pollution is exported: * fpsetsticky(). * FP*FLD, FP*OFF and FP*REG from */ >How-To-Repeat: Compile this code with c++ -Wall: #include int main() { fp_rnd_t r; fp_prec_t p; fp_except_t e; r = fpgetround(); r = fpsetround(r); p = fpgetprec(); p = fpsetprec(p); e = fpgetmask(); e = fpsetmask(e); e = fpgetsticky(); e = fpresetsticky(e); } >Fix: *** /usr/include/floatingpoint.h Tue Oct 21 15:14:26 1997 --- floatingpoint.h Fri Jan 1 05:22:59 2038 *************** *** 108,121 **** /* * SysV/386 FP control interface */ ! #define fpgetround() ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF) ! #define fpsetround(m) __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF) ! #define fpgetprec() ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF) ! #define fpsetprec(m) __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF) ! #define fpgetmask() ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF) ! #define fpsetmask(m) __fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF) ! #define fpgetsticky() ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF) ! #define fpresetsticky(m) __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF) #define fpsetsticky(m) fpresetsticky(m) #endif /* !_FLOATINGPOINT_H_ */ --- 108,121 ---- /* * SysV/386 FP control interface */ ! #define fpgetround() ((fp_rnd_t) ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF)) ! #define fpsetround(m) ((fp_rnd_t) __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF)) ! #define fpgetprec() ((fp_prec_t) ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF)) ! #define fpsetprec(m) ((fp_prec_t) __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF)) ! #define fpgetmask() ((fp_except_t) ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF)) ! #define fpsetmask(m) ((fp_except_t) (__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF))) ! #define fpgetsticky() ((fp_except_t) ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF)) ! #define fpresetsticky(m) ((fp_except_t) __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF)) #define fpsetsticky(m) fpresetsticky(m) #endif /* !_FLOATINGPOINT_H_ */ >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message