public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime @ 2021-02-02 9:55 matthieum.147192 at gmail dot com 2021-10-02 6:10 ` [Bug c++/98930] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: matthieum.147192 at gmail dot com @ 2021-02-02 9:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98930 Bug ID: 98930 Summary: ICE when using function local static constexpr variable at runtime Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matthieum.147192 at gmail dot com Target Milestone: --- The following code crashes gcc trunk (11.0) and produces a linker error on prior versions -- from 7.2 to 10.2.1 -- from -O0 to -O3. Link to compiler explorer: https://godbolt.org/z/qox73Y Self-sufficient code snippet: template <char const* format> class Source { public: explicit Source() noexcept { asm volatile("" : : "r,m"(format) : "memory"); } int index() const noexcept { return 0; } }; template <typename T> T impl() { static constexpr const char FORMAT_[] = "Hello, {}!"; static Source<FORMAT_> const SOURCE{}; return SOURCE.index(); } int main() { return impl<int>(); } GCC trunk crash: <source>: In instantiation of 'Source<format>::Source() [with const char* format = (& FORMAT_)]': <source>:4:14: required from here <source>:4:14: internal compiler error: in discriminator_for_local_entity, at cp/mangle.c:1949 4 | explicit Source() noexcept { | ^~~~~~ 0x1ce5ce9 internal_error(char const*, ...) ???:0 0x6b6f1b fancy_abort(char const*, int, char const*) ???:0 0x812f3b mangle_decl(tree_node*) ???:0 0x135b052 decl_assembler_name(tree_node*) ???:0 0x138e478 assign_assembler_name_if_needed(tree_node*) ???:0 0xb48015 cgraph_node::analyze() ???:0 0xb4c6dd symbol_table::finalize_compilation_unit() ???:0 GCC 10.2 linker error: /opt/compiler-explorer/gcc-10.2.0/bin/../lib/gcc/x86_64-linux-gnu/10.2.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/cc6YCcxH.o: in function `_ZN6SourceIXadL_ZZ4implIT_ES1_vE7FORMAT_EEEC1Ev': /home/ce/<source>:5: undefined reference to `_ZZ4implIT_ES0_vE7FORMAT_' collect2: error: ld returned 1 exit status Other compilers: ICE on Clang 11.0, Works on Clang (trunk). In the same area (local static constexpr) I found 2 bug reports: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95686 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98288 (which I reported) Regards. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98930] ICE when using function local static constexpr variable at runtime 2021-02-02 9:55 [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime matthieum.147192 at gmail dot com @ 2021-10-02 6:10 ` pinskia at gcc dot gnu.org 2021-10-02 6:12 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-10-02 6:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98930 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 98288 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98930] ICE when using function local static constexpr variable at runtime 2021-02-02 9:55 [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime matthieum.147192 at gmail dot com 2021-10-02 6:10 ` [Bug c++/98930] " pinskia at gcc dot gnu.org @ 2021-10-02 6:12 ` pinskia at gcc dot gnu.org 2021-10-02 6:21 ` [Bug c++/98930] ICE with static variable in template function used as template argument pinskia at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-10-02 6:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98930 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-10-02 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98930] ICE with static variable in template function used as template argument 2021-02-02 9:55 [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime matthieum.147192 at gmail dot com 2021-10-02 6:10 ` [Bug c++/98930] " pinskia at gcc dot gnu.org 2021-10-02 6:12 ` pinskia at gcc dot gnu.org @ 2021-10-02 6:21 ` pinskia at gcc dot gnu.org 2021-10-05 13:50 ` cvs-commit at gcc dot gnu.org 2021-10-05 13:53 ` ppalka at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-10-02 6:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98930 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|ICE when using function |ICE with static variable in |local static constexpr |template function used as |variable at runtime |template argument --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Shortest testcase: template <int* format> struct g { g() { *format =1; } }; template <int> void impl() { static int i=1; static g<&i> h{}; } int main() { impl<0>(); return 0; } ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98930] ICE with static variable in template function used as template argument 2021-02-02 9:55 [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime matthieum.147192 at gmail dot com ` (2 preceding siblings ...) 2021-10-02 6:21 ` [Bug c++/98930] ICE with static variable in template function used as template argument pinskia at gcc dot gnu.org @ 2021-10-05 13:50 ` cvs-commit at gcc dot gnu.org 2021-10-05 13:53 ` ppalka at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-10-05 13:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98930 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:f3930418cb82000fae3cb4e98e870428800cf295 commit r12-4186-gf3930418cb82000fae3cb4e98e870428800cf295 Author: Patrick Palka <ppalka@redhat.com> Date: Tue Oct 5 09:50:02 2021 -0400 c++: templated static local var has value-dep addr [PR98930] Here uses_template_parms returns false for the dependent type A<&impl::i>, which causes tsubst_aggr_type to think it's non-dependent and not bother substituting into it, leading to breakage. This patch fixes this by making has_value_dependent_address also return true for templated static local variables. PR c++/98930 gcc/cp/ChangeLog: * pt.c (has_value_dependent_address): Return true for a static local variable from a function template. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/nontype4.C: New test. * g++.dg/cpp1z/nontype4a.C: New test. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98930] ICE with static variable in template function used as template argument 2021-02-02 9:55 [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime matthieum.147192 at gmail dot com ` (3 preceding siblings ...) 2021-10-05 13:50 ` cvs-commit at gcc dot gnu.org @ 2021-10-05 13:53 ` ppalka at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: ppalka at gcc dot gnu.org @ 2021-10-05 13:53 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98930 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.0 Resolution|--- |FIXED Status|NEW |RESOLVED CC| |ppalka at gcc dot gnu.org --- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 12, thanks for the bug report. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-05 13:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-02 9:55 [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime matthieum.147192 at gmail dot com 2021-10-02 6:10 ` [Bug c++/98930] " pinskia at gcc dot gnu.org 2021-10-02 6:12 ` pinskia at gcc dot gnu.org 2021-10-02 6:21 ` [Bug c++/98930] ICE with static variable in template function used as template argument pinskia at gcc dot gnu.org 2021-10-05 13:50 ` cvs-commit at gcc dot gnu.org 2021-10-05 13:53 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).