Skip to content
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

reference to local binding fails in enclosing function #48582

Closed
yurivict opened this issue Feb 18, 2021 · 6 comments
Closed

reference to local binding fails in enclosing function #48582

yurivict opened this issue Feb 18, 2021 · 6 comments
Labels
bugzilla Issues migrated from bugzilla c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" worksforme Resolved as "works for me"

Comments

@yurivict
Copy link

Bugzilla Link 49238
Version 12.0
OS FreeBSD
Attachments testcase-clang.cpp
CC @zygoloid

Extended Description

The attached testcase fails in clang++{9,10,11}:

testcase-clang.cpp:11:16: error: reference to local binding 'a' declared in enclosing function 'f'
return a+b;
^
testcase-clang.cpp:9:11: note: 'a' declared here
auto [a, b] = newTuple();
^
testcase-clang.cpp:11:18: error: reference to local binding 'b' declared in enclosing function 'f'
return a+b;
^
testcase-clang.cpp:9:14: note: 'b' declared here
auto [a, b] = newTuple();
^
2 errors generated.

It succeeds in gcc-10.

@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2021

(For reference, if I understand correctly, this should be allowed by P1091R3 and/or P1381R1; I have also tested this against clang 12.0.5.)

@llvmbot
Copy link
Member

llvmbot commented Aug 15, 2021

Yes C++20 does fix this but Clang still complains about it.

@yurivict
Copy link
Author

I just checked clang-14 - it is still affected.

Is there an estimate when this will be fixed?

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@planetmarshall
Copy link

Short test case on Compiler Explorer

https://godbolt.org/z/n99xe57vs

@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Mar 4, 2022
@llvmbot
Copy link
Member

llvmbot commented Mar 4, 2022

@llvm/issue-subscribers-clang-frontend

ibis-hdl pushed a commit to ibis-hdl/x3-playground that referenced this issue Jul 7, 2022
- move char_parser to own header
- add decimal_literal parser
- adder basic convert functions
- Hit Clang's [reference to local binding fails in enclosing function #48582](
  llvm/llvm-project#48582)
- cosmetic printing
- using constexpr LUT for exp base 10
@chausner
Copy link

chausner commented Oct 8, 2022

Short test case on Compiler Explorer

https://godbolt.org/z/n99xe57vs

Seems the issue has been fixed in the latest development version (clang (trunk) on Compiler Explorer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" worksforme Resolved as "works for me"
Projects
None yet
Development

No branches or pull requests

5 participants