Issue 181530
Summary visibility of template functions during subsitution and std::tuple
Labels new issue
Assignees
Reporter ribbon-otter
    The following code compiles in clang but not gcc or msvc. It appears that when gcc or msvc fails, it is because the forward declaration don't cause all of the definitions of foo to be visible while evaluating `decltype`. Clang evaluates the `decltype` after the forward declarations. Given that gcc fails with `std::tuple` but not a custom type suggests that maybe gcc has a bug, but I don't want to report the bug to multiple projects until someone more knowledgeable of the spec confirms what the behaviour is supposed to be.

https://godbolt.org/z/e5oG6Gcn9
```c++
#include <tuple>

//declare the templates
constexpr int foo(int a);

template<template<class> class T, class Td>
constexpr T<decltype(foo(std::declval<Td>()))>
foo(T<Td> a);

//----- then define them
constexpr int foo(int a);

template<template<class> class T, class Td>
constexpr T<decltype(foo(std::declval<Td>()))>
foo(T<Td> a){return {};};

template<class T> struct A {};
template<class... A> struct my_tuple{};

int main() {
    foo(A<my_tuple<int>>{}); //this works in gcc for some reason (msvc fails)
    foo(A<std::tuple<int>>{});  //this fails in gcc
    return 0;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to