NetBSD Problem Report #48187

From www@NetBSD.org  Thu Sep  5 21:57:06 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 9430670F1C
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  5 Sep 2013 21:57:06 +0000 (UTC)
Message-Id: <20130905215704.C67D671008@mollari.NetBSD.org>
Date: Thu,  5 Sep 2013 21:57:04 +0000 (UTC)
From: justin@specialbusservice.com
Reply-To: justin@specialbusservice.com
To: gnats-bugs@NetBSD.org
Subject: multiple definitions of same macros in headers
X-Send-Pr-Version: www-1.0

>Number:         48187
>Category:       lib
>Synopsis:       multiple definitions of same macros in headers
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 05 22:00:00 +0000 2013
>Originator:     Justin Cormack
>Release:        6.1 (and cvs)
>Organization:
>Environment:
NetBSD netbsd32.myriabit.eu 6.1 NetBSD 6.1 (XEN3PAE_DOMU) i386
>Description:
There is a set of constants that are defined in multiple places in the NetBSD headers, without #ifdefs around either set, so some header combinations conflict.

The constants in question are: FLT_DIG, FLT_MIN, FLT_MAX and DBL_DIG, DBL_MIN, DBL_MAX.

These are defined (as per C89) via float.h, but actually in sys/float_ieee754.h - the definitions here generally use the gcc definitions where available and have various cases, plus define the other associated constants that C89 defines.

However these are also defined in /usr/include/i386/limits.h (and, if you check, for all other architectures eg /usr/include/amd64/limits.h on amd64, plus other architectures if you check the source). These are only protected by #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) which are obviously often defined.

Because these are system headers, the warnings for these redefinitions are hidden without -Wsystem-headers (which is not in -Wall); I noticed when cross compiling NetBSD, where these were not "system" headers, also if you use -nostdinc -I/usr/include where they are not system.

>How-To-Repeat:
test.c:

#include <machine/limits.h>

#include <sys/float_ieee754.h>

int main() {
  return FLT_DIG;
}

compile with
gcc -D_XOPEN_SOURCE=500 -D_NETBSD_SOURCE -Wall -Werror -Wsystem-headers test.c

Note you need -Wsystem-headers or it will be hidden by default. However this is an issue when cross compiling parts of NetBSD libc, in particular libc/gdtoa and libm as these include float.h as these are not being used as system headers when cross compiling. Plus it is a bug even if this warning is not a default, just less visible.


>Fix:
Remove FLT_DIG from limits.h and include float.h instead where needed.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.