[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Patrick Palka changed: What|Removed |Added Status|NEW |RESOLVED CC||ppalka at gcc dot gnu.org Resolution|--- |FIXED Target Milestone|--- |14.0 Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org --- Comment #10 from Patrick Palka --- Fixed for GCC 14
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 --- Comment #9 from GCC Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:ea7bebff7cc5a5eb780a6ca646cb77cad1b625d6 commit r14-6595-gea7bebff7cc5a5eb780a6ca646cb77cad1b625d6 Author: Patrick Palka Date: Fri Dec 15 10:03:31 2023 -0500 c++: section attribute on templates [PR70435, PR88061] The section attribute currently has no effect on templates because the call to set_decl_section_name only happens at parse time (on the dependent decl) and not also at instantiation time. This patch fixes this by propagating the section name from the template to the instantiation. PR c++/70435 PR c++/88061 gcc/cp/ChangeLog: * pt.cc (tsubst_function_decl): Propagate DECL_SECTION_NAME via set_decl_section_name. (tsubst_decl) : Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/attr-section1.C: New test. * g++.dg/ext/attr-section1a.C: New test. * g++.dg/ext/attr-section2.C: New test. * g++.dg/ext/attr-section2a.C: New test. * g++.dg/ext/attr-section2b.C: New test.
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Klaus Rudolph changed: What|Removed |Added CC||lts-rudolph at gmx dot de --- Comment #8 from Klaus Rudolph --- Bug still present in 11.2.1
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Strager Neds changed: What|Removed |Added CC||strager.nds at gmail dot com --- Comment #7 from Strager Neds --- I also encountered this bug. I started fixing this bug (and PR 88061): https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00348.html
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Felix Jones changed: What|Removed |Added CC||fewix3000 at hotmail dot co.uk --- Comment #6 from Felix Jones --- Related bug 88061 Here's a demonstration of the issue with GCC trunk x86-64 on godbolt: https://godbolt.org/z/9GFWZR Minimal example for reproducing: > template > Type __attribute__( ( used, section( ".my_section" ) ) ) add_types( Type a, > Type b ) { >return a + b; > } > > int main( int argc, char * argv[] ) { >return test_class( s_value<3> ).add( add_types( 1, 2 ) ); > } Current behaviour: add_types within section .text Desired behaviour: add_types within section .my_section Clang trunk demonstrates the desired behaviour: https://godbolt.org/z/t8FNe0
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Khalil changed: What|Removed |Added CC||kammce at google dot com --- Comment #5 from Khalil --- Having similiar issues with ARM Embedded and Linux GCC. Having trouble finding a work around for this. Here is an example code that demonstrates the issue in our particular use case: === // g++ -std=c++17 static.cpp -o static.exe // // objdump -t static.exe | grep thing // 0740 u O .rodata 0064 _ZZ5test0ILi5EEvvE5thing // // clang -std=c++14 static.cpp -o static.exe // objdump -t static.exe | grep thing // 004005d3 w O .log_entry 0064 _ZZ5test0ILi5EEvvE5thing #include #if __APPLE__ #define PUT_IN_SECTION(name) __attribute__((section("__text," name), used)) #else #define PUT_IN_SECTION(name) __attribute__((section(name), used)) #endif struct ThingType { constexpr ThingType(const char * str): data{} { for(int i = 0; str[i] != '\0' && i < sizeof(data); i++) { data[i] = str[i]; } } char data[100]; }; template void test0() { PUT_IN_SECTION(".log_entry") static const ThingType thing("Goodbye!"); printf("Hello, World!\n"); } int main() { test0(); return 0; } === Comment the test0 template line out, and the entry will appear in the appropriate section.
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Martin Sebor changed: What|Removed |Added Keywords||wrong-code Status|UNCONFIRMED |NEW Last reconfirmed||2018-09-14 CC||msebor at gcc dot gnu.org Ever confirmed|0 |1 Known to fail||5.3.0, 6.4.0, 7.3.0, 8.2.0, ||9.0 --- Comment #4 from Martin Sebor --- Confirmed with the top of trunk.
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 --- Comment #3 from Matheus Izvekov --- Still an issue in gcc 8.2.0.
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 --- Comment #2 from Armin van der Togt --- Problem is still present in version 6.3.1
[Bug c++/70435] section attribute of a function template is not honored.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 Armin van der Togt changed: What|Removed |Added CC||armin at otheruse dot nl --- Comment #1 from Armin van der Togt --- I am having the same problem with static member variables: #include class TestClassRegular { public: static volatile const int32_t regularVar; }; volatile const int32_t TestClassRegular::regularVar __attribute__ ((section(".eepromdata.ints"))) = 0; template class TestClassTemplate { public: static volatile const int32_t templateVar; }; template volatile const int32_t TestClassTemplate::templateVar __attribute__ ((section(".eepromdata.ints"))) = 0; int main() { int32_t blah = TestClassRegular::regularVar + TestClassTemplate<10, uint8_t>::templateVar; return blah; } arm-none-eabi-objdump -t stm32l0-Template.elf | grep Var 20c4 wO .data 0004 _ZN17TestClassTemplateILm10EhE11templateVarE 08080008 g O .eepromdata0004 _ZN16TestClassRegular10regularVarE