[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #22 from Dan Urosu --- Thank you for your help and explanations! For now, I found an acceptable solution for my real project.

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #19 from Dan Urosu --- (In reply to Marek Polacek from comment #18) > But is unwrap_1 called in such a way that 'r' binds to a temporary? Did you mean 'u' binds to a temporary? In this case r1 is a temporary object and a reference

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #17 from Dan Urosu --- I just tried something after you explained how this warning works. The most common cause of a real dangling ref is not caught unfortunately. If you replace the unwrap_1 impl with the below you get no warning.

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #15 from Dan Urosu --- (In reply to Dan Urosu from comment #14) > Thanks for clarifying (1) > I think I can work-around with the pragma. Will try something shortly in the > real code. > > > Can you please elaborate on this "Right,

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 Dan Urosu changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|---

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #11 from Dan Urosu --- 1) "We don't analyze the body of the function" unwrap_1 and unwrap_2 are functionally equivalent. Yet only unwrap_2 triggers the warning. 2) If the unwrap_2 is called from a macro, then the pragma suppression d

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #8 from Dan Urosu --- Why does not warn for unwarp_1? The mere addition of an unused template parameter triggers this warning. Also "decorating the unwrap_2 function to tell the compiler not to warn there." does not work if we have

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #7 from Dan Urosu --- Why does not warn for unwarp_1? The mere addition of an unused template parameter triggers this warning.

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #6 from Dan Urosu --- Using the macro with the unwrap_1 does not error. The GCC behavior is very weird. On Thursday, July 18, 2024 at 12:44:21 PM EDT, Dan Urosu wrote: Ah indeed, but... In the real use case we call it fr

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #5 from Dan Urosu --- Ah indeed, but... In the real use case we call it from macro. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdangling-reference" template     const T& unwrap_2(const Wrapper& r, FUNC&&) { // n

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #3 from Dan Urosu --- The 109642 is not a duplicate of the attached code. The error is the same but the code that causes it is completely different. Also, the "solution" to disable the warning/error is not actually resolving the iss

[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 --- Comment #2 from Dan Urosu --- Hi Andrew, I cannot use "#pragma GCC diagnostic ignored" because we have thousands of call sites where we plan to use this kind of code. And we don't want to disable globally this warning either. Would "no_da

[Bug c++/115987] New: False "possibly dangling reference" false positive when having an extra template parameter

2024-07-18 Thread durosu at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 Bug ID: 115987 Summary: False "possibly dangling reference" false positive when having an extra template parameter Product: gcc Version: 13.3.1 Status: UNCONFIRMED