Bug 843436

Summary: #define DBL_EPSILON ignored
Product: [Fedora] Fedora Reporter: nucleo <alekcejk>
Component: mingw-headersAssignee: Erik van Pienbroek <erik-fedora>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: alekcejk, erik-fedora, kalevlember, ktietz, rjones
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-17 14:22:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
scratch build log in rawhide none

Description nucleo 2012-07-26 10:31:47 UTC
Created attachment 600476 [details]
scratch build log in rawhide

Description of problem:
"#define DBL_EPSILON     __DBL_EPSILON__" from /usr/lib/gcc/i686-w64-mingw32/4.7.0/include/float.h ignored when building opencv:
http://nucleo.fedorapeople.org/rpms/mingw-opencv/mingw-opencv-2.4.2-1.fc17.src.rpm


Version-Release number of selected component (if applicable):
mingw32-headers-2.0.999-0.6.trunk.20120601.fc17.noarch

How reproducible:
Build filed for opencv but this simple test example compiles fine:
#include <float.h>
#include <stdio.h>

int main(void)
{
    printf("DBL_EPSILON: %d\n", DBL_EPSILON);
}

Also opencv builds fine if all bundled libs libjasper, libjpeg, libpng, libtiff and zlib built instead of using mingw libs (-DBUILD_ZLIB=ON -DBUILD_TIFF=ON -DBUILD_JASPER=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON)

  
Actual results:
/builddir/build/BUILD/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts_perf.hpp:166:89: error: 'DBL_EPSILON' was not declared in this scope

Additional info:
This is what file BUILD/OpenCV-2.4.2/build_win32shared/modules/core/CMakeFiles/opencv_perf_core_pch_dephelp.dir/depend.make contains:

modules/core/CMakeFiles/opencv_perf_core_pch_dephelp.dir/opencv_perf_core_pch_dephelp.cxx.obj: /usr/i686-w64-mingw32/sys-root/mingw/include/float.h

Adding lines 
#define DBL_EPSILON __DBL_EPSILON__
and 
#define FLT_EPSILON __FLT_EPSILON__
in /usr/i686-w64-mingw32/sys-root/mingw/include/float.h fixes build, so looks like "#define DBL_EPSILON     __DBL_EPSILON__" from /usr/lib/gcc/i686-w64-mingw32/4.7.0/include/float.h ignored.

Comment 1 Kalev Lember 2012-07-26 10:59:29 UTC
It is missing an '#include <float.h>' in ts_perf.hpp.

Comment 2 nucleo 2012-07-26 11:17:50 UTC
Nothing changed after I added '#include <float.h>' in ts_perf.hpp.
Looks like float.h used even without adding this #include because it builds after modifying /usr/i686-w64-mingw32/sys-root/mingw/include/float.h.

Comment 3 Kalev Lember 2012-07-26 11:55:00 UTC
I took a closer look at this and it's passing "-isystem /usr/i686-w64-mingw32/sys-root/mingw/include" to g++, which overrides the order of gcc's internal includes.

While normally /usr/lib64/gcc/i686-w64-mingw32/4.7.0/include precedes /usr/i686-w64-mingw32/sys-root/mingw/include, the use of -isystem reverses the order.

Apparently with gcc 4.6 and newer, the mingw-w64 headers expect that gcc's include directory always comes first. The #include_next <float.h> in mingw-w64's float.h is guarded by __GNUC__ == 4 && __GNUC_MINOR__ < 6.

Kai, are the float.h headers supposed to still correctly include the other one if the system include directory order is swapped?

Comment 4 Kai Tietz 2012-07-26 13:39:55 UTC
The order of system-include directories is right now fixed.  We expect that gcc's internal include comes before the standard include directory.
Of course this might cause issues with -isystem, so a patch for this upstream could be a solution.
Does it help to revome the guard __GNUC__ == 4 && _GNUC_MINGW_ < 6?

Comment 5 nucleo 2012-07-26 17:41:59 UTC
(In reply to comment #4)
> The order of system-include directories is right now fixed.  We expect that
> gcc's internal include comes before the standard include directory.
> Of course this might cause issues with -isystem, so a patch for this
> upstream could be a solution.
> Does it help to revome the guard __GNUC__ == 4 && _GNUC_MINGW_ < 6?

I modified /usr/i686-w64-mingw32/sys-root/mingw/include/float.h:

--- float.h.orig        2012-07-05 21:54:45.000000000 +0300
+++ float.h     2012-07-26 20:37:54.216850282 +0300
@@ -13,7 +13,7 @@
 
 #if (defined (__GNUC__) && defined (__GNUC_MINOR__)) \
     || (defined(__clang__) && defined(__clang_major__))
-#if (__GNUC__ < 4  || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) \
+#if (__GNUC__ < 4  ) \
     || (__clang_major__ >=3)
 #if !defined(_FLOAT_H___) && !defined(__FLOAT_H)
 #include_next <float.h>


But compilation failed with the same error:

In file included from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts.hpp:583:0,
                 from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/modules/core/perf/perf_precomp.hpp:8,
                 from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/build_win32shared/modules/core/opencv_perf_core_pch_dephelp.cxx:1:
/home/user/rpmbuild/BUILD/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts_perf.hpp:163:88: error: 'DBL_EPSILON' was not declared in this scope

Comment 6 nucleo 2012-07-26 20:27:37 UTC
The only place where I found -isystem is cmake/OpenCVPCHSupport.cmake, but looks like -isystem added even after removing line "sed -i '/_PCH_isystem_prefix/d' cmake/OpenCVPCHSupport.cmake".

Comment 7 nucleo 2012-07-27 19:45:18 UTC
I placed files /usr/lib/gcc/i686-w64-mingw32/4.7.0/include/float.h in /usr/i686-w64-mingw32/sys-root/mingw/include/ and /usr/i686-w64-mingw32/sys-root/mingw/include/float.h in /usr/lib/gcc/i686-w64-mingw32/4.7.0/include/ but still getting the same error.

Comment 8 nucleo 2012-08-01 00:43:42 UTC
Now I got other error after this modification of /usr/i686-w64-mingw32/sys-root/mingw/include/float.h:

--- float.h.orig        2012-07-05 21:54:45.000000000 +0300
+++ float.h     2012-08-01 03:39:20.474592779 +0300
@@ -13,8 +13,6 @@
 
 #if (defined (__GNUC__) && defined (__GNUC_MINOR__)) \
     || (defined(__clang__) && defined(__clang_major__))
-#if (__GNUC__ < 4  || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) \
-    || (__clang_major__ >=3)
 #if !defined(_FLOAT_H___) && !defined(__FLOAT_H)
 #include_next <float.h>
 #endif
@@ -113,7 +111,6 @@
        #define _FLOAT_H___
 #endif
 #endif
-#endif
 
 #ifndef _MINGW_FLOAT_H_
 #define _MINGW_FLOAT_H_


New build error:

In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/float.h:17:0,
                 from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/modules/core/include/opencv2/core/types_c.h:58,
                 from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/modules/core/include/opencv2/core/core.hpp:49,
                 from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/modules/core/src/precomp.hpp:50,
                 from /home/user/rpmbuild/BUILD/OpenCV-2.4.2/build_win32shared/modules/core/opencv_core_pch_dephelp.cxx:1:
/usr/lib/gcc/i686-w64-mingw32/4.7.0/include/float.h:279:24: fatal error: float.h: No such file or directory

Comment 9 nucleo 2012-08-01 08:48:05 UTC
If I additionally to changes from Comment 8 remove this line in file /usr/lib/gcc/i686-w64-mingw32/4.7.0/include/float.h:

#include_next <float.h>

then it compiles fine.

So maybe possible fix needs adding some kind of ifdefs for #include_next in /usr/lib/gcc/i686-w64-mingw32/4.7.0/include/float.h and modification of ifdefs in /usr/i686-w64-mingw32/sys-root/mingw/include/float.h ?

Comment 10 Fedora End Of Life 2013-04-03 14:50:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 11 Erik van Pienbroek 2014-05-29 13:32:23 UTC
Is this issue still valid on modern Fedora environments?
I can't build the SRPM you mentioned here as it depends on cuda which isn't in Fedora and I don't know where its RPM package can be found

Comment 12 Fedora End Of Life 2015-01-09 17:17:00 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 13 Fedora End Of Life 2015-02-17 14:22:14 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 14 Red Hat Bugzilla 2023-09-14 01:36:24 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days