Issue 79734
Summary Clang Issues Deprecation Warning on System Headers with Small C++ Modules Project
Labels
Assignees
Reporter gen740
    ## Step to reproduce
- Create the following two `.ccm` files.
```cpp
// std_module.ccm
module;

#include<vector>

export module std_modules;

export namespace std {
    using std::vector;
};

// A.ccm
export module A;

import std_modules;

auto test() {
 std::vector<int>().push_back(42);
}
```
- Compile with the following commands.
```
$CXX -std=c++20 -stdlib=libc++ -Wdeprecated-declarations -c std_modules.ccm -fmodule-output=std_modules.pcm
$CXX -std=c++20 -stdlib=libc++ -Wdeprecated-declarations -c A.ccm -fmodule-output=A.pcm -fmodule-file=std_modules=std_modules.pcm
```

## Output
```
In module 'std_modules' imported from A.ccm:3:
/usr/lib/llvm-18/bin/../include/c++/v1/__iterator/reverse_iterator.h:53:14: warning: 'iterator<std::random_access_iterator_tag, int>' is deprecated [-Wdeprecated-declarations]
   53 |     : public iterator<typename iterator_traits<_Iter>::iterator_category,
      | ^
/usr/lib/llvm-18/bin/../include/c++/v1/vector:991:33: note: in instantiation of template class 'std::reverse_iterator<int *>' requested here
  991 |                      __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
      | ^
/usr/lib/llvm-18/bin/../include/c++/v1/vector:1455:3: note: in instantiation of member function 'std::__1::vector<int>::__swap_out_circular_buffer' requested here
 1455 | __swap_out_circular_buffer(__v);
      | ^
/usr/lib/llvm-18/bin/../include/c++/v1/vector:1479:13: note: in instantiation of function template specialization 'std::__1::vector<int>::__push_back_slow_path<int>' requested here
 1479 | __end = __push_back_slow_path(std::move(__x));
      | ^
A.ccm:6:23: note: in instantiation of member function 'std::__1::vector<int>::push_back' requested here
    6 | std::vector<int>().push_back(32);
      | ^
/usr/lib/llvm-18/bin/../include/c++/v1/__iterator/iterator.h:23:29: note: 'iterator<std::random_access_iterator_tag, int>' has been explicitly marked deprecated here
   23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator {
      | ^
/usr/lib/llvm-18/bin/../include/c++/v1/__config:1006:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
 1006 | #    define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
      | ^
/usr/lib/llvm-18/bin/../include/c++/v1/__config:979:49: note: expanded from macro '_LIBCPP_DEPRECATED'
  979 | #      define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
      | ^
1 warning generated.
```

## Environment
- ubuntu 22.04 (docker)
- clang (Installed from https://apt.llvm.org)
```
Ubuntu clang version 18.1.0 (++20240127043115+ed48280f8e9d-1~exp1~20240127043233.6)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

## Additional context
I could reproduce this warning on Compile Explorer (https://godbolt.org/z/157e981MY).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to