public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114772] New: pragma GCC target applied to earlier template function with __attribute__((warn_unused_result))
@ 2024-04-18 15:36 mjires at gcc dot gnu.org
  2024-04-18 15:40 ` [Bug c++/114772] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mjires at gcc dot gnu.org @ 2024-04-18 15:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114772

            Bug ID: 114772
           Summary: pragma GCC target applied to earlier template function
                    with __attribute__((warn_unused_result))
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mjires at gcc dot gnu.org
                CC: jamborm at gcc dot gnu.org
  Target Milestone: ---

Following minimized testcase fails depending on warn_unused_result attribute.
Fails at least since GCC 10.

$ cat simdjson.cpp
template<typename V, bool STREAMING>
inline __attribute__((always_inline))
#ifdef FAIL
__attribute__((warn_unused_result))
#endif
int walk_document(V visitor) {return 0;}

template<bool STREAMING>
void parse_document() {
    int r = walk_document<bool, STREAMING>(false);
}

void stage2_next() {
    parse_document<true>();
}

#pragma GCC target("pclmul")



$ gcc simdjson.cpp -DFAIL
simdjson.cpp: In function ‘void parse_document() [with bool STREAMING = true]’:
simdjson.cpp:6:5: error: inlining failed in call to ‘always_inline’ ‘int
walk_document(V) [with V = bool; bool STREAMING = true]’: target specific
option mismatch
    6 | int walk_document(V visitor) {return 0;}
      |     ^~~~~~~~~~~~~
simdjson.cpp:10:43: note: called from here
   10 |     int r = walk_document<bool, STREAMING>(false);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~



Without __attribute__((warn_unused_result)) it compiles without problems.

Inlining is denied in ix86_can_inline_p, because:
caller: void parse_document() [with bool STREAMING = true]/1
callee: int walk_document(V) [with V = bool; bool STREAMING = true]/2
caller_opts->x_ix86_isa_flags: 000c001100000012
callee_opts->x_ix86_isa_flags: 000c009100000012
So they differ by OPTION_MASK_ISA_PCLMUL

Source of this difference seems to be attribs.cc:decl_attributes, which is
called during template instantiation, but uses global_options.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-21  9:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18 15:36 [Bug c++/114772] New: pragma GCC target applied to earlier template function with __attribute__((warn_unused_result)) mjires at gcc dot gnu.org
2024-04-18 15:40 ` [Bug c++/114772] " pinskia at gcc dot gnu.org
2024-04-19 12:50 ` [Bug c++/114772] [13/14 Regression] pragma GCC target applied to earlier template function with __attribute__((warn_unused_result)) since r12-6904 jakub at gcc dot gnu.org
2024-05-21  9:20 ` [Bug c++/114772] [13/14/15 " jakub 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).