GCC 9.2 math.h misuse in favor of /usr/include one

Basically. I downloaded GCC 9.2.0 from Unixpackages (with all of its dependencies), setuped path, manpath and ld library path to correctly use the package, gcc itself can compile just in C, but when you try to compile in C++ it simply cannot, telling that things arent defined in /usr/include/math.h, however, while the math.h in GCC 9.2 directory is different to the one in /usr/include, Solaris use the /usr/include one instead of the gcc 9.2 one, any help would be appreciated, thanks for your time and attention

@JohnKCG ohnKCG......Welcome to the forums.

However, I find your explanation of your problem about as clear as mud.

Are you only using Solaris? Or are you cross-testing on another platform as well?

What works (without error) and what doesn't?

If you want to force the use of a particular include file can't you simply edit the source code and enter the full pathname of the include file that you want to use?

1)Only Solaris 10 Sparc, January 2020 patch set, no VMs, Zones, Ldoms or whatever, in a user created account (not root)

2)The only thing that works is C compiling and runninf, C++ doesn't compile or run anything, it says that the math.h file in /usr/include hasn't defined the functions of C++ (ismore, isless, etc), while the math.h in /usr/local/gcc9/include does, however gcc uses the math.h located in /usr/include, leading to this bug

Something to note is that I didn't remove the old pre-installed gcc that Sol 10 (2013 version) brought, I guess that maybe recompiling the header files (which also includes the math.h) with the newer gcc may or may not fix the issue, however I rm -r the math.h in /usr/include and replaced it with the one located in /usr/local/gcc9/include and it brought like 100+ bugs to the terminal, so maybe my approach isn't the best

3)I will be honest, I am pretty much a noob, so frankly, I don't know how to do that.

If you need logs, photos or whatever you think is needed to have more insight on the matter, tell me, thanks for your time @hicksd8

after retrieving all pertinent logs and articles, there it's a decent answer to what you asked me:

the problem is that there is a conflict between the math.h and other libraries included with the gcc 9.2.0 package provided by unixpackages located at /usr/local/gcc9/include/c++ and the math.h library bundled with solaris 10 located in /usr/include the bug isnt new, in fact it has been reported before:

GCC 4.5.2, 4.7.3, and 4.8.2 Packages Do Not Provide include-fixed Header Files - Oracle® Solaris 11.2 Release Notes (even if it isnt solaris 10 directly, I considered it pertinent)

as you can see, the same bug is reproduced by a earlier gcc version, with the cause being a bug with c++ 11 and beyond, explaining why it only fails when compiling even hello wolrd in c++, here is the code and output with c++:

#include <iostream>

int 
main ()
{
  std::cout << "Hello, world!\n";
  return 0;
}

$ g++ -Wall -c hello.cc
In file included from /usr/local/gcc9/include/c++/9.2.0/bits/std_abs.h:40,
                 from /usr/local/gcc9/include/c++/9.2.0/cstdlib:77,
                 from /usr/local/gcc9/include/c++/9.2.0/ext/string_conversions.h:41,
                 from /usr/local/gcc9/include/c++/9.2.0/bits/basic_string.h:6493,                 from /usr/local/gcc9/include/c++/9.2.0/string:55,
                 from /usr/local/gcc9/include/c++/9.2.0/bits/locale_classes.h:40,                 from /usr/local/gcc9/include/c++/9.2.0/bits/ios_base.h:41,
                 from /usr/local/gcc9/include/c++/9.2.0/ios:42,
                 from /usr/local/gcc9/include/c++/9.2.0/ostream:38,
                 from /usr/local/gcc9/include/c++/9.2.0/iostream:39,
                 from hello.cc:1:
/usr/include/math.h:45:12: error: 'std::float_t' has not been declared
   45 | using std::float_t;
      |            ^~~~~~~
/usr/include/math.h:46:12: error: 'std::double_t' has not been declared
   46 | using std::double_t;
      |            ^~~~~~~~
/usr/include/math.h:48:12: error: 'std::fpclassify' has not been declared
   48 | using std::fpclassify;
      |            ^~~~~~~~~~
/usr/include/math.h:49:12: error: 'std::isfinite' has not been declared
   49 | using std::isfinite;
      |            ^~~~~~~~
/usr/include/math.h:50:12: error: 'std::isinf' has not been declared
   50 | using std::isinf;
      |            ^~~~~
/usr/include/math.h:51:12: error: 'std::isnan' has not been declared
   51 | using std::isnan;
      |            ^~~~~
/usr/include/math.h:52:12: error: 'std::isnormal' has not been declared
   52 | using std::isnormal;
      |            ^~~~~~~~
/usr/include/math.h:53:12: error: 'std::signbit' has not been declared
   53 | using std::signbit;
      |            ^~~~~~~
/usr/include/math.h:55:12: error: 'std::isgreater' has not been declared
   55 | using std::isgreater;
      |            ^~~~~~~~~
/usr/include/math.h:56:12: error: 'std::isgreaterequal' has not been declared
   56 | using std::isgreaterequal;
      |            ^~~~~~~~~~~~~~
/usr/include/math.h:57:12: error: 'std::isless' has not been declared
   57 | using std::isless;
      |            ^~~~~~
/usr/include/math.h:58:12: error: 'std::islessequal' has not been declared
   58 | using std::islessequal;
      |            ^~~~~~~~~~~
/usr/include/math.h:59:12: error: 'std::islessgreater' has not been declared
   59 | using std::islessgreater;
      |            ^~~~~~~~~~~~~
/usr/include/math.h:60:12: error: 'std::isunordered' has not been declared
   60 | using std::isunordered;
      |            ^~~~~~~~~~~
/usr/include/math.h:62:12: error: 'std::acosh' has not been declared
   62 | using std::acosh;
      |            ^~~~~
/usr/include/math.h:63:12: error: 'std::asinh' has not been declared
   63 | using std::asinh;
      |            ^~~~~
/usr/include/math.h:64:12: error: 'std::atanh' has not been declared
   64 | using std::atanh;
      |            ^~~~~
/usr/include/math.h:65:12: error: 'std::cbrt' has not been declared
   65 | using std::cbrt;
      |            ^~~~
/usr/include/math.h:66:12: error: 'std::copysign' has not been declared
   66 | using std::copysign;
      |            ^~~~~~~~
/usr/include/math.h:67:12: error: 'std::erf' has not been declared
   67 | using std::erf;
      |            ^~~
/usr/include/math.h:68:12: error: 'std::erfc' has not been declared
   68 | using std::erfc;
      |            ^~~~
/usr/include/math.h:69:12: error: 'std::exp2' has not been declared
   69 | using std::exp2;
      |            ^~~~
/usr/include/math.h:70:12: error: 'std::expm1' has not been declared
   70 | using std::expm1;
      |            ^~~~~
/usr/include/math.h:71:12: error: 'std::fdim' has not been declared
   71 | using std::fdim;
      |            ^~~~
/usr/include/math.h:72:12: error: 'std::fma' has not been declared
   72 | using std::fma;
      |            ^~~
/usr/include/math.h:73:12: error: 'std::fmax' has not been declared
   73 | using std::fmax;
      |            ^~~~
/usr/include/math.h:74:12: error: 'std::fmin' has not been declared
   74 | using std::fmin;
      |            ^~~~
/usr/include/math.h:75:12: error: 'std::hypot' has not been declared
   75 | using std::hypot;
      |            ^~~~~
/usr/include/math.h:76:12: error: 'std::ilogb' has not been declared
   76 | using std::ilogb;
      |            ^~~~~
/usr/include/math.h:77:12: error: 'std::lgamma' has not been declared
   77 | using std::lgamma;
      |            ^~~~~~
/usr/include/math.h:78:12: error: 'std::llrint' has not been declared
   78 | using std::llrint;
      |            ^~~~~~
/usr/include/math.h:79:12: error: 'std::llround' has not been declared
   79 | using std::llround;
      |            ^~~~~~~
/usr/include/math.h:80:12: error: 'std::log1p' has not been declared
   80 | using std::log1p;
      |            ^~~~~
/usr/include/math.h:81:12: error: 'std::log2' has not been declared
   81 | using std::log2;
      |            ^~~~
/usr/include/math.h:82:12: error: 'std::logb' has not been declared
   82 | using std::logb;
      |            ^~~~
/usr/include/math.h:83:12: error: 'std::lrint' has not been declared
   83 | using std::lrint;
      |            ^~~~~
/usr/include/math.h:84:12: error: 'std::lround' has not been declared
   84 | using std::lround;
      |            ^~~~~~
/usr/include/math.h:85:12: error: 'std::nan' has not been declared
   85 | using std::nan;
      |            ^~~
/usr/include/math.h:86:12: error: 'std::nanf' has not been declared
   86 | using std::nanf;
      |            ^~~~
/usr/include/math.h:87:12: error: 'std::nanl' has not been declared
   87 | using std::nanl;
      |            ^~~~
/usr/include/math.h:88:12: error: 'std::nearbyint' has not been declared
   88 | using std::nearbyint;
      |            ^~~~~~~~~
/usr/include/math.h:89:12: error: 'std::nextafter' has not been declared
   89 | using std::nextafter;
      |            ^~~~~~~~~
/usr/include/math.h:90:12: error: 'std::nexttoward' has not been declared
   90 | using std::nexttoward;
      |            ^~~~~~~~~~
/usr/include/math.h:91:12: error: 'std::remainder' has not been declared
   91 | using std::remainder;
      |            ^~~~~~~~~
/usr/include/math.h:92:12: error: 'std::remquo' has not been declared
   92 | using std::remquo;
      |            ^~~~~~
/usr/include/math.h:93:12: error: 'std::rint' has not been declared
   93 | using std::rint;
      |            ^~~~
/usr/include/math.h:94:12: error: 'std::round' has not been declared
   94 | using std::round;
      |            ^~~~~
/usr/include/math.h:95:12: error: 'std::scalbln' has not been declared
   95 | using std::scalbln;
      |            ^~~~~~~
/usr/include/math.h:96:12: error: 'std::scalbn' has not been declared
   96 | using std::scalbn;
      |            ^~~~~~
/usr/include/math.h:97:12: error: 'std::tgamma' has not been declared
   97 | using std::tgamma;
      |            ^~~~~~
/usr/include/math.h:98:12: error: 'std::trunc' has not been declared
   98 | using std::trunc;
      |            ^~~~~

That is the bug in question, as previously mentioned, only affects c++ compilation, with C, all works fine, no bugs there.

In the first link I posted, the last answer says that Oracle "fixed it" with a patch, while its true that they updated the math.h library with a patch, it doesnt fix it since my machine has the reccomended patchset from january of this year, anyway, I will append Oracle math.h code:

Oracle's updated math.h:

/*
 * Copyright (c) 1993, 2015, Oracle and/or its affiliates. All rights reserved.
 */

#if __cplusplus >= 201103L
#undef	_GLIBCXX_USE_C99_MATH
#undef	_GLIBCXX_USE_C99_MATH_TR1
#endif

#ifndef _MATH_H
#define	_MATH_H

/* @(#)math.h	2.26	16/02/27 */

#include <iso/math_iso.h>
#include <iso/math_c99.h>

#if __cplusplus >= 199711L
using std::abs;
using std::acos;
using std::asin;
using std::atan2;
using std::atan;
using std::ceil;
using std::cos;
using std::cosh;
using std::exp;
using std::fabs;
using std::floor;
using std::fmod;
using std::frexp;
using std::ldexp;
using std::log10;
using std::log;
using std::modf;
using std::pow;
using std::sin;
using std::sinh;
using std::sqrt;
using std::tan;
using std::tanh;
#endif

#if  __cplusplus >= 201103L
using std::float_t;
using std::double_t;

using std::fpclassify;
using std::isfinite;
using std::isinf;
using std::isnan;
using std::isnormal;
using std::signbit;

using std::isgreater;
using std::isgreaterequal;
using std::isless;
using std::islessequal;
using std::islessgreater;
using std::isunordered;

using std::acosh;
using std::asinh;
using std::atanh;
using std::cbrt;
using std::copysign;
using std::erf;
using std::erfc;
using std::exp2;
using std::expm1;
using std::fdim;
using std::fma;
using std::fmax;
using std::fmin;
using std::hypot;
using std::ilogb;
using std::lgamma;
using std::llrint;
using std::llround;
using std::log1p;
using std::log2;
using std::logb;
using std::lrint;
using std::lround;
using std::nan;
using std::nanf;
using std::nanl;
using std::nearbyint;
using std::nextafter;
using std::nexttoward;
using std::remainder;
using std::remquo;
using std::rint;
using std::round;
using std::scalbln;
using std::scalbn;
using std::tgamma;
using std::trunc;
#endif	/* __cplusplus >= 201103L */

#ifdef __cplusplus
extern "C" {
#endif

#if defined(__cplusplus) && (defined(__GNUC__) || \
	defined(__MATHERR_RENAME_EXCEPTION))
#define	exception	__math_exception
#endif

#ifndef __P
#ifdef __STDC__
#define	__P(p)	p
#else
#define	__P(p)	()
#endif
#endif	/* !defined(__P) */

#if defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) || \
	!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)
/*
 * SVID & X/Open
 */
#define	M_E		2.7182818284590452354
#define	M_LOG2E		1.4426950408889634074
#define	M_LOG10E	0.43429448190325182765
#define	M_LN2		0.69314718055994530942
#define	M_LN10		2.30258509299404568402
#define	M_PI		3.14159265358979323846
#define	M_PI_2		1.57079632679489661923
#define	M_PI_4		0.78539816339744830962
#define	M_1_PI		0.31830988618379067154
#define	M_2_PI		0.63661977236758134308
#define	M_2_SQRTPI	1.12837916709551257390
#define	M_SQRT2		1.41421356237309504880
#define	M_SQRT1_2	0.70710678118654752440

extern int signgam;

#define	MAXFLOAT	((float)3.40282346638528860e+38)

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
/*
 * SVID
 */
enum version {libm_ieee = -1, c_issue_4, ansi_1, strict_ansi};

#ifdef __STDC__
extern const enum version _lib_version;
#else
extern enum version _lib_version;
#endif

struct exception {
	int type;
	char *name;
	double arg1;
	double arg2;
	double retval;
};

#define	HUGE		MAXFLOAT

#define	_ABS(x)		((x) < 0 ? -(x) : (x))

#define	_REDUCE(TYPE, X, XN, C1, C2)	{ \
	double x1 = (double)(TYPE)X, x2 = X - x1; \
	X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); }

#define	DOMAIN		1
#define	SING		2
#define	OVERFLOW	3
#define	UNDERFLOW	4
#define	TLOSS		5
#define	PLOSS		6

#define	_POLY1(x, c)	((c)[0] * (x) + (c)[1])
#define	_POLY2(x, c)	(_POLY1((x), (c)) * (x) + (c)[2])
#define	_POLY3(x, c)	(_POLY2((x), (c)) * (x) + (c)[3])
#define	_POLY4(x, c)	(_POLY3((x), (c)) * (x) + (c)[4])
#define	_POLY5(x, c)	(_POLY4((x), (c)) * (x) + (c)[5])
#define	_POLY6(x, c)	(_POLY5((x), (c)) * (x) + (c)[6])
#define	_POLY7(x, c)	(_POLY6((x), (c)) * (x) + (c)[7])
#define	_POLY8(x, c)	(_POLY7((x), (c)) * (x) + (c)[8])
#define	_POLY9(x, c)	(_POLY8((x), (c)) * (x) + (c)[9])
#endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */

/*
 * SVID & X/Open
 */
/* BEGIN adopted by C99 */
extern double erf __P((double));
extern double erfc __P((double));
extern double hypot __P((double, double));
extern double lgamma __P((double));

#if !defined(__cplusplus) && defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(erf, erfc, hypot)
#pragma does_not_write_global_data(erf, erfc, hypot)
#pragma no_side_effect(erf, erfc, hypot)
#endif

#if !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && \
	!defined(__C99FEATURES__) && __cplusplus - 0 < 201103L
extern int isnan __P((double));

#pragma does_not_read_global_data(isnan)
#pragma does_not_write_global_data(isnan)
#pragma no_side_effect(isnan)
#endif
/* END adopted by C99 */

#if defined(__EXTENSIONS__) || _XOPEN_SOURCE - 0 < 600
extern double gamma __P((double));		/* deprecated; use lgamma */
#endif
extern double j0 __P((double));
extern double j1 __P((double));
extern double jn __P((int, double));
extern double y0 __P((double));
extern double y1 __P((double));
extern double yn __P((int, double));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(j0, j1, jn, y0, y1, yn)
#pragma does_not_write_global_data(j0, j1, jn, y0, y1, yn)
#pragma no_side_effect(j0, j1, jn, y0, y1, yn)
#endif
#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || \
	_XOPEN_SOURCE - 0 >= 500 || \
	defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1
#if defined(__EXTENSIONS__) || _XOPEN_SOURCE - 0 < 700
/*
 * SVID & XPG 4.2/5
 */
extern double scalb __P((double, double));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(scalb)
#pragma does_not_write_global_data(scalb)
#pragma no_side_effect(scalb)
#endif
#endif

/* BEGIN adopted by C99 */
extern double acosh __P((double));
extern double asinh __P((double));
extern double atanh __P((double));
extern double cbrt __P((double));
extern double logb __P((double));
extern double nextafter __P((double, double));
extern double remainder __P((double, double));

/*
 * XPG 4.2/5
 */
extern double expm1 __P((double));
extern int ilogb __P((double));
extern double log1p __P((double));
extern double rint __P((double));

#if !defined(__cplusplus) && defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(acosh, asinh, atanh, cbrt)
#pragma does_not_read_global_data(logb, nextafter, remainder)
#pragma does_not_read_global_data(expm1, ilogb, log1p, rint)
#pragma does_not_write_global_data(acosh, asinh, atanh, cbrt)
#pragma does_not_write_global_data(logb, nextafter, remainder)
#pragma does_not_write_global_data(expm1, ilogb, log1p, rint)
#pragma no_side_effect(acosh, asinh, atanh, cbrt)
#pragma no_side_effect(logb, nextafter, remainder)
#pragma no_side_effect(expm1, ilogb, log1p, rint)
#endif
/* END adopted by C99 */
#endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || ... */

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
/*
 * SVID
 */
extern int matherr __P((struct exception *));

/*
 * IEEE Test Vector
 */
extern double significand __P((double));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(significand)
#pragma does_not_write_global_data(significand)
#pragma no_side_effect(significand)
#endif

extern int signgamf;				/* deprecated; use signgam */
extern int signgaml;				/* deprecated; use signgam */

extern int isnanf __P((float));
extern int isnanl __P((long double));
extern float gammaf __P((float));		/* deprecated; use lgammaf */
extern float gammaf_r __P((float, int *));	/* deprecated; use lgammaf_r */
extern float j0f __P((float));
extern float j1f __P((float));
extern float jnf __P((int, float));
extern float lgammaf_r __P((float, int *));
extern float scalbf __P((float, float));
extern float significandf __P((float));
extern float y0f __P((float));
extern float y1f __P((float));
extern float ynf __P((int, float));
extern long double gammal __P((long double));	/* deprecated; use lgammal */
extern long double gammal_r __P((long double, int *));	/* deprecated */
extern long double j0l __P((long double));
extern long double j1l __P((long double));
extern long double jnl __P((int, long double));
extern long double lgammal_r __P((long double, int *));
extern long double scalbl __P((long double, long double));
extern long double significandl __P((long double));
extern long double y0l __P((long double));
extern long double y1l __P((long double));
extern long double ynl __P((int, long double));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(isnanf, isnanl)
#pragma does_not_write_global_data(isnanf, isnanl)
#pragma no_side_effect(isnanf, isnanl)
#pragma does_not_read_global_data(gammaf_r, j0f, j1f, jnf, lgammaf_r, scalbf)
#pragma does_not_read_global_data(significandf, y0f, y1f, ynf)
#pragma does_not_write_global_data(j0f, j1f, jnf, scalbf)
#pragma does_not_write_global_data(significandf, y0f, y1f, ynf)
#pragma no_side_effect(j0f, j1f, jnf, scalbf)
#pragma no_side_effect(significandf, y0f, y1f, ynf)
#pragma does_not_read_global_data(gammal_r, j0l, j1l, jnl, lgammal_r, scalbl)
#pragma does_not_read_global_data(significandl, y0l, y1l, ynl)
#pragma does_not_write_global_data(j0l, j1l, jnl, scalbl)
#pragma does_not_write_global_data(significandl, y0l, y1l, ynl)
#pragma no_side_effect(j0l, j1l, jnl, scalbl)
#pragma no_side_effect(significandl, y0l, y1l, ynl)
#endif

/*
 * for sin+cos->sincos transformation
 */
extern void sincos __P((double, double *, double *));
extern void sincosf __P((float, float *, float *));
extern void sincosl __P((long double, long double *, long double *));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(sincos, sincosf, sincosl)
#endif

/* BEGIN adopted by C99 */
/*
 * Functions callable from C, intended to support IEEE arithmetic.
 */
extern double copysign __P((double, double));
extern double scalbn __P((double, int));

#if !defined(__cplusplus) && defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(copysign, scalbn)
#pragma does_not_write_global_data(copysign, scalbn)
#pragma no_side_effect(copysign, scalbn)
#endif
/* END adopted by C99 */

/*
 * Reentrant version of gamma & lgamma; passes signgam back by reference
 * as the second argument; user must allocate space for signgam.
 */
extern double gamma_r __P((double, int *));	/* deprecated; use lgamma_r */
extern double lgamma_r __P((double, int *));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(gamma_r, lgamma_r)
#endif

/* BEGIN adopted by C99 */
extern float modff __P((float, float *));

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(modff)
#endif
/* END adopted by C99 */

#if defined(__EXTENSIONS__) || !defined(__cplusplus)
#include <floatingpoint.h>
#endif
#endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */
#endif	/* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) || ... */

#if defined(__cplusplus) && (defined(__GNUC__) || \
	defined(__MATHERR_RENAME_EXCEPTION))
#undef	exception
#endif

#ifdef __cplusplus
}
#endif

#endif	/* _MATH_H */

thats it, I really dont know what to do now... again, thanks for your time @hicksd8