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

#embed interacts poorly with template argument deduction and initializer lists #122306

Open
cor3ntin opened this issue Jan 9, 2025 · 4 comments
Labels
c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" rejects-valid

Comments

@cor3ntin
Copy link
Contributor

cor3ntin commented Jan 9, 2025

Clang incorrectly rejects the following because it fails to deduce the correct size for the array/initializer list

static constexpr auto std_to_char_array = std::to_array<char>({
         #embed __FILE__
         , '\0'
    });
  static constexpr auto initializer_list = std::initializer_list<char>{
      #embed __FILE__
       , '\0'
  };

https://godbolt.org/z/4oj8Tr4d5

(From reddit)

@cor3ntin cor3ntin added c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" rejects-valid labels Jan 9, 2025
@cor3ntin
Copy link
Contributor Author

cor3ntin commented Jan 9, 2025

@Fznamznon

@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2025

@llvm/issue-subscribers-clang-frontend

Author: cor3ntin (cor3ntin)

Clang incorrectly rejects the following because it fails to deduce the correct size for the array/initializer list ```cpp

static constexpr auto std_to_char_array = std::to_array<char>({
#embed FILE
, '\0'
});
static constexpr auto initializer_list = std::initializer_list<char>{
#embed FILE
, '\0'
};


https://godbolt.org/z/4oj8Tr4d5

([From reddit](https://www.reddit.com/r/cpp/comments/1hxdv17/experimenting_with_embed/))
</details>

@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2025

@llvm/issue-subscribers-c-1

Author: cor3ntin (cor3ntin)

Clang incorrectly rejects the following because it fails to deduce the correct size for the array/initializer list ```cpp

static constexpr auto std_to_char_array = std::to_array<char>({
#embed FILE
, '\0'
});
static constexpr auto initializer_list = std::initializer_list<char>{
#embed FILE
, '\0'
};


https://godbolt.org/z/4oj8Tr4d5

([From reddit](https://www.reddit.com/r/cpp/comments/1hxdv17/experimenting_with_embed/))
</details>

@pinskia
Copy link

pinskia commented Jan 9, 2025

Note I filed a bug for GCC here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118390 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" rejects-valid
Projects
None yet
Development

No branches or pull requests

3 participants