{"url":"https://api.github.com/repos/llvm/llvm-project/issues/92425","repository_url":"https://api.github.com/repos/llvm/llvm-project","labels_url":"https://api.github.com/repos/llvm/llvm-project/issues/92425/labels{/name}","comments_url":"https://api.github.com/repos/llvm/llvm-project/issues/92425/comments","events_url":"https://api.github.com/repos/llvm/llvm-project/issues/92425/events","html_url":"https://github.com/llvm/llvm-project/pull/92425","id":2300822117,"node_id":"PR_kwDOBITxeM5vsHzi","number":92425,"title":"[Clang][Sema] ASTContext::getUnconstrainedType propagates dependence","user":{"login":"sdkrystian","id":16629302,"node_id":"MDQ6VXNlcjE2NjI5MzAy","avatar_url":"https://avatars.githubusercontent.com/u/16629302?v=4","gravatar_id":"","url":"https://api.github.com/users/sdkrystian","html_url":"https://github.com/sdkrystian","followers_url":"https://api.github.com/users/sdkrystian/followers","following_url":"https://api.github.com/users/sdkrystian/following{/other_user}","gists_url":"https://api.github.com/users/sdkrystian/gists{/gist_id}","starred_url":"https://api.github.com/users/sdkrystian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdkrystian/subscriptions","organizations_url":"https://api.github.com/users/sdkrystian/orgs","repos_url":"https://api.github.com/users/sdkrystian/repos","events_url":"https://api.github.com/users/sdkrystian/events{/privacy}","received_events_url":"https://api.github.com/users/sdkrystian/received_events","type":"User","user_view_type":"public","site_admin":false},"labels":[{"id":1958965060,"node_id":"MDU6TGFiZWwxOTU4OTY1MDYw","url":"https://api.github.com/repos/llvm/llvm-project/labels/clang","name":"clang","color":"79b5d1","default":false,"description":"Clang issues not falling into any other category"},{"id":1958998266,"node_id":"MDU6TGFiZWwxOTU4OTk4MjY2","url":"https://api.github.com/repos/llvm/llvm-project/labels/clang:frontend","name":"clang:frontend","color":"3b12ce","default":false,"description":"Language frontend issues, e.g. anything involving \"Sema\""}],"state":"closed","locked":false,"assignees":[],"milestone":null,"comments":1,"created_at":"2024-05-16T16:16:12Z","updated_at":"2024-05-16T18:10:47Z","closed_at":"2024-05-16T18:10:46Z","assignee":null,"author_association":"MEMBER","issue_field_values":[],"type":null,"active_lock_reason":null,"draft":false,"pull_request":{"url":"https://api.github.com/repos/llvm/llvm-project/pulls/92425","html_url":"https://github.com/llvm/llvm-project/pull/92425","diff_url":"https://github.com/llvm/llvm-project/pull/92425.diff","patch_url":"https://github.com/llvm/llvm-project/pull/92425.patch","merged_at":"2024-05-16T18:10:46Z"},"body":"When the argument passed to `ASTContext::getUnconstrainedType` is an unconstrained `AutoType`, will return the argument unchanged. However, when called with a constrained `AutoType`, an unconstrained, non-dependent `AutoType` will be returned even if the argument was dependent. Consider the following:\r\n```cpp\r\ntemplate<typename T>\r\nconcept C = sizeof(T) == sizeof(int);\r\n\r\ntemplate<auto N>\r\nstruct A;\r\n\r\ntemplate<C auto N>\r\nstruct A<N>; // error: class template partial specialization is not more specialized than the primary template\r\n```\r\nWhen comparing the template parameters for equivalence, `ASTContext::getUnconstrainedType` is used to remove the constraints per [[temp.over.link] p6 sentence 2](http://eel.is/c++draft/temp.over.link#6.sentence-2). For the template parameter `N` of the class template, it returns a dependent `AutoType`. For the template parameter `N` of the class template partial specialization, it returns a non-dependent `AutoType`. We subsequently compare the adjusted types and find they are not equivalent, thus we consider the partial specialization to not be more specialized than the primary template per [[temp.func.order] p6.2.2](http://eel.is/c++draft/temp.func.order#6.2.2). \r\n\r\nThis patch changes `ASTContext::getUnconstrainedType` such that the dependence of a constrained `AutoType` will propagate to the returned unconstrained `AutoType`. This causes the above example to be correctly accepted, fixing #77377.","closed_by":{"login":"sdkrystian","id":16629302,"node_id":"MDQ6VXNlcjE2NjI5MzAy","avatar_url":"https://avatars.githubusercontent.com/u/16629302?v=4","gravatar_id":"","url":"https://api.github.com/users/sdkrystian","html_url":"https://github.com/sdkrystian","followers_url":"https://api.github.com/users/sdkrystian/followers","following_url":"https://api.github.com/users/sdkrystian/following{/other_user}","gists_url":"https://api.github.com/users/sdkrystian/gists{/gist_id}","starred_url":"https://api.github.com/users/sdkrystian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdkrystian/subscriptions","organizations_url":"https://api.github.com/users/sdkrystian/orgs","repos_url":"https://api.github.com/users/sdkrystian/repos","events_url":"https://api.github.com/users/sdkrystian/events{/privacy}","received_events_url":"https://api.github.com/users/sdkrystian/received_events","type":"User","user_view_type":"public","site_admin":false},"reactions":{"url":"https://api.github.com/repos/llvm/llvm-project/issues/92425/reactions","total_count":1,"+1":1,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"timeline_url":"https://api.github.com/repos/llvm/llvm-project/issues/92425/timeline","performed_via_github_app":null,"state_reason":null}