Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator errors in cppyy #17157

Open
1 task done
akira-okumura opened this issue Nov 30, 2024 · 0 comments
Open
1 task done

operator errors in cppyy #17157

akira-okumura opened this issue Nov 30, 2024 · 0 comments

Comments

@akira-okumura
Copy link

Check duplicate issues.

  • Checked for duplicates

Description

The cppyy distribution included in ROOT emits different errors for 1 + c, 1. + c, and c + 1., where c is cppyy.gbl.std.complex['double']. Wim @wlav recommended me to report this behavior in the following issue report of cppyy.
wlav/cppyy#277

$ ipython
Python 3.13.0 (main, Oct  7 2024, 05:02:14) [Clang 16.0.0 (clang-1600.0.26.4)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.29.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cppyy

In [2]: cppyy.__path__
Out[2]: ['/usr/local/root-6.32.08_install/lib/cppyy']

In [3]: c = cppyy.gbl.std.complex['double'](1, 1)

In [4]: 1 + c
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[4], line 1
----> 1 1 + c

NotImplementedError: 
In [1]: import cppyy

In [2]: c = cppyy.gbl.std.complex['double'](1, 1)

In [3]: c + 1.
In module 'std' imported from input_line_1:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:53:56: error: no type named 'iterator_category' in 'std::iterator_traits<double>'
    : public iterator<typename iterator_traits<_Iter>::iterator_category,
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:302:20: note: in instantiation of template class 'std::reverse_iterator<double>' requested here
operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) {
                   ^
input_line_22:7:124: note: while substituting explicitly-specified template arguments into function template 'operator+' 
      new (ret) (std::complex<double>) (((std::complex<double> (&)(const std::complex<double> &, const double &))std::__1::operator+<double>)((const std::complex<double>&)*(const std::complex<double>*)args[0], (const double&)*(const double*)args[1]));
                                                                                                                           ^
In module 'std' imported from input_line_1:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:81:44: error: no type named 'iterator_category' in 'std::iterator_traits<double>'
          typename iterator_traits<_Iter>::iterator_category>;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:82:52: error: no type named 'pointer' in 'std::iterator_traits<double>'
  using pointer = typename iterator_traits<_Iter>::pointer;
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:89:60: error: no type named 'value_type' in 'std::iterator_traits<double>'
  using value_type      = typename iterator_traits<_Iter>::value_type;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:90:60: error: no type named 'difference_type' in 'std::iterator_traits<double>'
  using difference_type = typename iterator_traits<_Iter>::difference_type;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:91:60: error: no type named 'reference' in 'std::iterator_traits<double>'
  using reference       = typename iterator_traits<_Iter>::reference;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In module 'std' imported from input_line_1:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/move_iterator.h:101:49: error: no type named 'iterator_category' in 'std::iterator_traits<double>'
               typename iterator_traits<_Iter>::iterator_category >
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/move_iterator.h:328:20: note: in instantiation of template class 'std::move_iterator<double>' requested here
operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) {
                   ^
input_line_22:7:124: note: while substituting explicitly-specified template arguments into function template 'operator+' 
      new (ret) (std::complex<double>) (((std::complex<double> (&)(const std::complex<double> &, const double &))std::__1::operator+<double>)((const std::complex<double>&)*(const std::complex<double>*)args[0], (const double&)*(const double*)args[1]));
                                                                                                                           ^
In module 'std' imported from input_line_1:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/move_iterator.h:103:52: error: no type named 'value_type' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::value_type value_type;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/move_iterator.h:104:52: error: no type named 'difference_type' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::difference_type difference_type;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/move_iterator.h:107:52: error: no type named 'reference' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::reference __reference;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In module 'std' imported from input_line_1:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/wrap_iter.h:31:52: error: no type named 'value_type' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::value_type value_type;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/wrap_iter.h:194:20: note: in instantiation of template class 'std::__wrap_iter<double>' requested here
operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT {
                   ^
input_line_22:7:124: note: while substituting explicitly-specified template arguments into function template 'operator+' 
      new (ret) (std::complex<double>) (((std::complex<double> (&)(const std::complex<double> &, const double &))std::__1::operator+<double>)((const std::complex<double>&)*(const std::complex<double>*)args[0], (const double&)*(const double*)args[1]));
                                                                                                                           ^
In module 'std' imported from input_line_1:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/wrap_iter.h:32:52: error: no type named 'difference_type' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::difference_type difference_type;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/wrap_iter.h:33:52: error: no type named 'pointer' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::pointer pointer;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/wrap_iter.h:34:52: error: no type named 'reference' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::reference reference;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/c++/v1/__iterator/wrap_iter.h:35:52: error: no type named 'iterator_category' in 'std::iterator_traits<double>'
  typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 c + 1.

ValueError: complex<double> std::operator+<double>(const complex<double>& __x, const double& __y) =>
    ValueError: nullptr result where temporary expected
In [1]: import cppyy

In [2]: c = cppyy.gbl.std.complex['double'](1, 1)

In [3]: 1. + c
Error in <TClass::GetMethodWithPrototype>: 
Did not find matching TMethod <operator+> with "double&, std::complex<double>&" for __1
Error in <TClass::GetMethodWithPrototype>: 
Did not find matching TMethod <operator+> with "double, std::complex<double>" for __1
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

Reproducer

Please see the above description.

ROOT version

   ------------------------------------------------------------------
  | Welcome to ROOT 6.32.08                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosxarm64 on Nov 26 2024, 08:17:22                   |
  | From tags/6-32-08@6-32-08                                        |
  | With Apple clang version 16.0.0 (clang-1600.0.26.4)              |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

Installation method

CMake build from the source

Operating system

macOS 15.1.1

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants