[Bug c++/97907] New: error when compiling with optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97907 Bug ID: 97907 Summary: error when compiling with optimization Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gustavo at ugr dot es Target Milestone: --- Created attachment 49596 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49596&action=edit source code and makefile, also available at https://pccito.ugr.es/bug/ and https://pccito.ugr.es/bug.tgz 3(5) should return 2 but it only works when no optimization level is applied. f1 and f2 are two dumb functions not intended to work. // g++ -O1 -save-temps -std=c11 -v -Wallpopcount.cc -o popcount #include unsigned f1(unsigned u) { unsigned c; asm("popcnt %0, %1":"+r"(c):"r"(u)); return c; } unsigned f2(unsigned u) { unsigned c; asm("popcnt %0, %1":"=r"(c),"=r"(u)); return c; } unsigned f3(unsigned u) { unsigned c; asm("popcnt %1, %0":"=r"(c):"r"(u)); return c; } int main() { std::cout << "f1(5) = " << f1(5) << std::endl << "f2(5) = " << f2(5) << std::endl << "f3(5) = " << f3(5) << std::endl; }
[Bug c++/97907] error when compiling with optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97907 --- Comment #2 from gustavo --- (In reply to Andreas Schwab from comment #1) > f1 invokes undefined behaviour by modifying an input-only asm operand. as expected... this is a test for students. only f3 matters.
[Bug libstdc++/91488] [9/10/11/12 Regression] char_traits::length causes "inlining failed in call to always_inline" error with -fgnu-tm -O2 -std=c++17
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91488 gustavo changed: What|Removed |Added CC||gustavo at ugr dot es --- Comment #5 from gustavo --- the bug is still here in gcc versión 11.1.1 20210531 (Red Hat 11.1.1-3) (GCC)
[Bug libstdc++/91488] [9/10/11/12 Regression] char_traits::length causes "inlining failed in call to always_inline" error with -fgnu-tm -O2 -std=c++17
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91488 --- Comment #6 from gustavo --- the bug is still here in gcc versión 11.1.1 20210531 (Red Hat 11.1.1-3) (GCC) g++ -fgnu-tm -O1 -Wallbug.cc -o bug In file included from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from bug.cc:2: /usr/include/c++/11/bits/char_traits.h: In static member function 'static constexpr std::size_t std::char_traits::length(const char_type*)': /usr/include/c++/11/bits/char_traits.h:257:5: error: inlining failed in call to 'always_inline' 'constexpr bool std::__constant_string_p(const _CharT*) [with _CharT = char]': 257 | __constant_string_p(const _CharT* __s) | ^~~ /usr/include/c++/11/bits/char_traits.h:368:32: note: called from here 368 | if (__constant_string_p(__s)) | ~~~^ /usr/include/c++/11/bits/char_traits.h:257:5: error: inlining failed in call to 'always_inline' 'constexpr bool std::__constant_string_p(const _CharT*) [with _CharT = char]': 257 | __constant_string_p(const _CharT* __s) | ^~~ /usr/include/c++/11/bits/char_traits.h:368:32: note: called from here 368 | if (__constant_string_p(__s)) | ~~~^ make: *** [: bug] Error 1
[Bug libstdc++/91488] [9/10/11/12 Regression] char_traits::length causes "inlining failed in call to always_inline" error with -fgnu-tm -O2 -std=c++17
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91488 --- Comment #7 from gustavo --- can be reproduced also trunk gcc in: https://gcc.godbolt.org/z/v6T9j3r4M