[Bug c++/117422] Error: template parameter was not declared in this scope

2025-04-14 Thread nerd.cpp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

--- Comment #7 from Jesse Williamson  ---
Revisiting this, I don't think it's a bug-- but perhaps a more specific error
message could have saved some confusion. 

See update: https://godbolt.org/z/sePdf4bvv

...adding scope resolution to the friend declaration in the class appears to
produce the correct match, so I'm thinking that the unqualified version was
causing the compiler to treat it as a forward declaration of a class member
rather than a free function:

template 
void f(T x) {}

/* Note: same error with:
void f(auto x) {}
*/

struct {
void f(int); 
friend void ::f<>(int); // <--- remove :: to see non-bug
} foo;

[Bug c++/117422] Error: template parameter was not declared in this scope

2025-03-29 Thread jesse at mind dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

Jesse Williamson  changed:

   What|Removed |Added

 CC||jesse at mind dot net

--- Comment #6 from Jesse Williamson  ---
*** Bug 119529 has been marked as a duplicate of this bug. ***

[Bug c++/117422] Error: template parameter was not declared in this scope

2024-11-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

--- Comment #5 from Andrew Pinski  ---
(In reply to eczbek.void from comment #4)
> Wow, very strange. Thanks for the workaround.

Most likely what is happening is the 2 decls are merged early and then the
template argument from the other decl is used instead of the new one which was
just declared. This is why comment #2 is happening :).

[Bug c++/117422] Error: template parameter was not declared in this scope

2024-11-02 Thread eczbek.void at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

--- Comment #4 from eczbek.void at gmail dot com ---
Wow, very strange. Thanks for the workaround.

[Bug c++/117422] Error: template parameter was not declared in this scope

2024-11-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

--- Comment #3 from Andrew Pinski  ---
Looks very similar to the issue of PR 100037  too.

[Bug c++/117422] Error: template parameter was not declared in this scope

2024-11-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||accepts-invalid

--- Comment #2 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #1)
> I think this might be a dup too since this is an old old bug.

At least it is related to PR 99 which shows that sometimes we mention the
template argument from the old one.

Note also you can make this accepts invalid too:
```
template
void f();

struct S {
template
friend void f() {
Q x;
}
};

int main() {
f();
}
```

[Bug c++/117422] Error: template parameter was not declared in this scope

2024-11-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2024-11-03
  Known to fail||3.4.6
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Keywords||rejects-valid

--- Comment #1 from Andrew Pinski  ---
Confirmed. 

Note obvious workaround is to name the original template argument in the
template definition of f to be T. Like so:
```
template
void f();
```


I think this might be a dup too since this is an old old bug.