Skip to content

[clang] Clang 19 reports "arithmetic on a pointer to an incomplete type" where Clang 18 and GCC do not #102293

Closed
@vient

Description

@vient

https://godbolt.org/z/sYPWjWqbo

struct _Destroy_aux {
  template <typename _ForwardIterator> static void __destroy(_ForwardIterator) {
    _ForwardIterator __first;
    ++__first;
  }
};

template <typename _ForwardIterator> void _Destroy(_ForwardIterator __last) {
  _Destroy_aux::__destroy(__last);
}

template <typename> struct allocator;

template <typename> struct allocator_traits;

template <typename _Tp> struct allocator_traits<allocator<_Tp>> {
  using pointer = _Tp *;
};

struct FileInfo;

struct __alloc_traits : allocator_traits<allocator<FileInfo>> {};

__alloc_traits::pointer _M_finish;

template <typename = int> struct vector {
  ~vector() { _Destroy(_M_finish); }
};

struct DatasetFactory {
  virtual ~DatasetFactory();
};

struct FileSystemDatasetFactory : DatasetFactory {
  vector<> v;
};
<source>:4:5: error: arithmetic on a pointer to an incomplete type 'FileInfo'
    4 |     ++__first;
      |     ^ ~~~~~~~
<source>:9:17: note: in instantiation of function template specialization '_Destroy_aux::__destroy<FileInfo *>' requested here
    9 |   _Destroy_aux::__destroy(__last);
      |                 ^
<source>:27:15: note: in instantiation of function template specialization '_Destroy<FileInfo *>' requested here
   27 |   ~vector() { _Destroy(_M_finish); }
      |               ^
<source>:34:8: note: in instantiation of member function 'vector<>::~vector' requested here
   34 | struct FileSystemDatasetFactory : DatasetFactory {
      |        ^
<source>:20:8: note: forward declaration of 'FileInfo'
   20 | struct FileInfo;
      |        ^
1 error generated.

Minified from Apache Arrow sources. Removing template from vector makes all compilers report the same error.

Is it a problem with Clang or with Arrow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"regression:19Regression in 19 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions