Skip to content

[C++20] [Modules] Error with modules, format, pipe operator - function with deduced return type cannot be used #61912

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

Open
rnikander opened this issue Apr 3, 2023 · 10 comments
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@rnikander
Copy link

rnikander commented Apr 3, 2023

This seems to be a bug.

https://godbolt.org/z/T7Y934rz3

Something bad happening with C++20 modules + <format> causes this confusing error. Remove the #include <format> and it goes away.

In module 'Mod' imported from /app/main.cc:2:
PartA.cc:13:32: error: function 'operator|<std::vector<int> &, std::__range_adaptor_closure_t<std::__bind_back_t<std::ranges::views::__drop::__fn, std::tuple<int>>>>' with deduced return type cannot be used before it is defined
        auto wtf = b_thing.vec | std::views::drop(1);
                               ^          
@EugeneZelenko EugeneZelenko added clang:modules C++20 modules and Clang Header Modules and removed new issue labels Apr 3, 2023
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2023

@llvm/issue-subscribers-clang-modules

@ChuanqiXu9 ChuanqiXu9 changed the title Error with modules, format, pipe operator - function with deduced return type cannot be used [C++20] [Modules] Error with modules, format, pipe operator - function with deduced return type cannot be used Apr 4, 2023
@ChuanqiXu9
Copy link
Member

Noted that the problem remains after I replace format to ranges: https://godbolt.org/z/1zs9346Tn. So it may doesn't matter with format but something in experimental library.

@dvirtz
Copy link

dvirtz commented Mar 13, 2024

Still seeing this error in Clang 18.1.0.
Any workarounds?

@ChuanqiXu9
Copy link
Member

It looks like the original reproducer doesn't work in upstream: https://godbolt.org/z/5cP4W8YrM

Would you like to provide a new reproducer? (And it will be better if it is reduced.)

@dvirtz
Copy link

dvirtz commented Mar 14, 2024

It reproduces across a library boundary: https://godbolt.org/z/7zac84afd

@ChuanqiXu9
Copy link
Member

Yeah, it looks like there indeed some problems in the compiler side. To push fixing the underlying issue, may we can try to get a reproducer with containing any system headers.

A workaround for users may be: https://godbolt.org/z/5srq6s1cd

Another suggestion is, given you're using libc++ in the reproducer, try to use the std module: https://libcxx.llvm.org/Modules.html

If you're using libstdc++ actually, I still suggesting to mock a std module by yourself. Due to https://clang.llvm.org/docs/StandardCPlusPlusModules.html#reduce-duplications

@rnikander
Copy link
Author

If you're using libstdc++ actually, I still suggesting to mock a std module by yourself. Due to

@ChuanqiXu9 I followed your link there for the advice on "reducing duplications". Do you know any tricks to deal with #define stuff? For example, I tried it with Vulkan, and it seems to work until I hit VK_NULL_HANDLE which is #define.

module;
#include <vulkan/vulkan.h>
export module vulkan;

export using ::VkWin32SurfaceCreateInfoKHR;
export using ::vkDestroySurfaceKHR;
...
export using ::VK_NULL_HANDLE;   // <--- nope...

@ChuanqiXu9
Copy link
Member

I didn't know it. It looks like some configuration is incorrect in vulkan or I misunderstand your problem.

@rnikander
Copy link
Author

I didn't know it. It looks like some configuration is incorrect in vulkan or I misunderstand your problem.

Vulkan is configured fine. I mean that I don't see how to re-export a symbol that is defined in the header file as a macro (#define VK_NULL_HANDLE ...). But maybe I shouldn't take this github issue off-topic. I can ask somewhere else. :)

@ChuanqiXu9
Copy link
Member

but modules can't export macros by the design...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

5 participants