Bug 82644 - Non-standard hypergeometric special functions defined in strict modes
Summary: Non-standard hypergeometric special functions defined in strict modes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.2
Assignee: Jonathan Wakely
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2017-10-21 00:45 UTC by Jonathan Wakely
Modified: 2018-06-19 13:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-10-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2017-10-21 00:45:22 UTC
#define hyperg 1                                                                                                                                                                                                                                                                                                             
#include <cmath>      

In C++17 this fails to compile:

hyper.cc:1:16: error: expected unqualified-id before numeric constant
 #define hyperg 1
                ^


hyperg is not a reserved name, so we shouldn't be defining it for -std=c++17, only -std=gnu++17
Comment 1 Jonathan Wakely 2017-10-21 00:48:28 UTC
While I'm on the subject, we fail to import the special functions into the global namespace in <math.h> (because the wrong macro is checked):

#include <math.h>
namespace test {
  using std::beta; // OK
  using ::beta;    // ERROR
}

specfun.cc:4:11: error: ‘::beta’ has not been declared
   using ::beta;    // ERROR
           ^~~~

And we don't properly document IS 29124 support, and implementation-defined behaviour.
Comment 2 Jonathan Wakely 2017-10-23 11:10:59 UTC
Author: redi
Date: Mon Oct 23 11:10:28 2017
New Revision: 254004

URL: https://gcc.gnu.org/viewcvs?rev=254004&root=gcc&view=rev
Log:
PR libstdc++/82644 document IS 29124 support

Also fix declarations of special functions in C++17, to import them into
the global namespace in <math.h>, and to prevent defining the
non-standard hypergeometric functions in strict mode.

	PR libstdc++/82644
	* doc/xml/manual/intro.xml: Include new section.
	* doc/xml/manual/status_cxxis29124.xml: New section on IS 29124
	status.
	* include/bits/specfun.h [__STRICT_ANSI__] (hyperg, hypergf, hypergl)
	(conf_hyperg, conf_hypergf, conf_hypergl): Don't declare.
	* include/c_compatibility/math.h: Import special functions into
	global namespace for C++17.
	* testsuite/26_numerics/headers/cmath/82644.cc: New test.
	* testsuite/26_numerics/headers/cmath/functions_global_c++17.cc: New
	test.

Added:
    trunk/libstdc++-v3/doc/xml/manual/status_cxxis29124.xml
    trunk/libstdc++-v3/testsuite/26_numerics/headers/cmath/82644.cc
    trunk/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_global_c++17.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/doc/xml/manual/intro.xml
    trunk/libstdc++-v3/include/bits/specfun.h
    trunk/libstdc++-v3/include/c_compatibility/math.h
Comment 3 Jonathan Wakely 2018-01-18 20:32:10 UTC
Author: redi
Date: Thu Jan 18 20:31:32 2018
New Revision: 256863

URL: https://gcc.gnu.org/viewcvs?rev=256863&root=gcc&view=rev
Log:
PR libstdc++/82644 document IS 29124 support

Backport from mainline
2017-10-23  Jonathan Wakely  <jwakely@redhat.com>

	* doc/xml/manual/intro.xml: Include new section.
	* doc/xml/manual/status_cxxis29124.xml: New section on IS 29124
	status.
	* doc/html/*: Regenerate.

Added:
    branches/gcc-7-branch/libstdc++-v3/doc/xml/manual/status_cxxis29124.xml
Modified:
    branches/gcc-7-branch/libstdc++-v3/ChangeLog
    branches/gcc-7-branch/libstdc++-v3/doc/html/index.html
    branches/gcc-7-branch/libstdc++-v3/doc/html/manual/bugs.html
    branches/gcc-7-branch/libstdc++-v3/doc/html/manual/index.html
    branches/gcc-7-branch/libstdc++-v3/doc/html/manual/intro.html
    branches/gcc-7-branch/libstdc++-v3/doc/html/manual/status.html
    branches/gcc-7-branch/libstdc++-v3/doc/xml/manual/intro.xml
Comment 4 Jonathan Wakely 2018-04-23 09:35:34 UTC
This is only fixed on trunk, but I think I planned to fix it for gcc-7 too.
Comment 5 Jonathan Wakely 2018-05-03 16:08:43 UTC
Bah, now we have failures for TR1 with -std=c++17 or -std=c++2a:


$ ~/gcc/8/bin/g++ -std=c++17 -include tr1/cmath -x c++ /dev/null 
In file included from <command-line>:
/home/jwakely/gcc/8/include/c++/8.0.1/tr1/cmath:1163:20: error: ‘__gnu_cxx::conf_hypergf’ has not been declared
   using __gnu_cxx::conf_hypergf;
                    ^~~~~~~~~~~~
/home/jwakely/gcc/8/include/c++/8.0.1/tr1/cmath:1164:20: error: ‘__gnu_cxx::conf_hypergl’ has not been declared
   using __gnu_cxx::conf_hypergl;
                    ^~~~~~~~~~~~
/home/jwakely/gcc/8/include/c++/8.0.1/tr1/cmath:1165:20: error: ‘__gnu_cxx::conf_hyperg’ has not been declared
   using __gnu_cxx::conf_hyperg;
                    ^~~~~~~~~~~
/home/jwakely/gcc/8/include/c++/8.0.1/tr1/cmath:1203:20: error: ‘__gnu_cxx::hypergf’ has not been declared
   using __gnu_cxx::hypergf;
                    ^~~~~~~
/home/jwakely/gcc/8/include/c++/8.0.1/tr1/cmath:1204:20: error: ‘__gnu_cxx::hypergl’ has not been declared
   using __gnu_cxx::hypergl;
                    ^~~~~~~
/home/jwakely/gcc/8/include/c++/8.0.1/tr1/cmath:1205:20: error: ‘__gnu_cxx::hyperg’ has not been declared
   using __gnu_cxx::hyperg;
                    ^~~~~~
Comment 6 Jonathan Wakely 2018-05-03 22:59:14 UTC
Author: redi
Date: Thu May  3 22:58:43 2018
New Revision: 259912

URL: https://gcc.gnu.org/viewcvs?rev=259912&root=gcc&view=rev
Log:
PR libstdc++/82644 define TR1 hypergeometric functions in strict modes

Following a recent change for PR 82644 the non-standard hypergeomtric
functions are not defined by <cmath> when __STRICT_ANSI__ is defined
(e.g. for -std=c++17, or -std=c++14 -D__STDCPP_WANT_MATH_SPEC_FUNCS__).
That caused errors in <tr1/cmath> because the using-declarations for
tr1::hyperg et al are invalid in strict modes.

The solution is to define the TR1 hypergeometric functions inline in
<tr1/cmath> if __STRICT_ANSI__ is defined.

	PR libstdc++/82644
	* include/tr1/cmath [__STRICT_ANSI__] (hypergf, hypergl, hyperg): Use
	inline definitions instead of using-declarations.
	[__STRICT_ANSI__] (conf_hypergf, conf_hypergl, conf_hyperg): Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	07_conf_hyperg/compile_cxx17.cc: New.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	17_hyperg/compile_cxx17.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/compile_cxx17.cc
    trunk/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/compile_cxx17.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/tr1/cmath
Comment 7 Jonathan Wakely 2018-06-19 13:17:16 UTC
Author: redi
Date: Tue Jun 19 13:16:44 2018
New Revision: 261743

URL: https://gcc.gnu.org/viewcvs?rev=261743&root=gcc&view=rev
Log:
PR libstdc++/82644 define TR1 hypergeometric functions in strict modes

Following a recent change for PR 82644 the non-standard hypergeomtric
functions are not defined by <cmath> when __STRICT_ANSI__ is defined
(e.g. for -std=c++17, or -std=c++14 -D__STDCPP_WANT_MATH_SPEC_FUNCS__).
That caused errors in <tr1/cmath> because the using-declarations for
tr1::hyperg et al are invalid in strict modes.

The solution is to define the TR1 hypergeometric functions inline in
<tr1/cmath> if __STRICT_ANSI__ is defined.

Backport from mainline
2018-05-03  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/82644
	* include/tr1/cmath [__STRICT_ANSI__] (hypergf, hypergl, hyperg): Use
	inline definitions instead of using-declarations.
	[__STRICT_ANSI__] (conf_hypergf, conf_hypergl, conf_hyperg): Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	07_conf_hyperg/compile_cxx17.cc: New.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	17_hyperg/compile_cxx17.cc: New.

Added:
    branches/gcc-8-branch/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/compile_cxx17.cc
    branches/gcc-8-branch/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/compile_cxx17.cc
Modified:
    branches/gcc-8-branch/libstdc++-v3/ChangeLog
    branches/gcc-8-branch/libstdc++-v3/include/tr1/cmath
Comment 8 Jonathan Wakely 2018-06-19 13:18:39 UTC
Fixed for 8.2

I'm not going to backport this to gcc-7-branch now, as it only affects C++17 mode and I think it's reasonable to tell people to use gcc-8 or trunk if they need these fixes.