public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100279] New: Invalid generated assembly for NTTP lambda with negative double value
@ 2021-04-27  1:33 bobmiller at nvidia dot com
  2021-04-27  4:58 ` [Bug c++/100279] " bobmiller at nvidia dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bobmiller at nvidia dot com @ 2021-04-27  1:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100279
           Summary: Invalid generated assembly for NTTP lambda with
                    negative double value
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bobmiller at nvidia dot com
  Target Milestone: ---

Created attachment 50683
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50683&action=edit
The preprocessed file that triggers the bug

I've stumbled across an obscure behavior that results in incorrect assembly
generation: the same signature is generated twice, which the assembler later
(correctly) rejects. I've tested this on GCC-11 and trunk, on my own machine
and godbolt ( example here: https://godbolt.org/z/6eEnKca9o )

Minimal example: 
----------------------------
template<auto V> struct T {};

template<class F> void E(F &&) {}

template<auto V, decltype(V)...Vs, class F>
void E(F &&f)
{
    f(T<V>{});
    E<Vs...>(f);
}

void foo()
{
    E<-1.0, -2.0>(
    [&]<auto X>(T<X>){});
}

int main(int, char**) {}
--------------------------

Interestingly, this does NOT occur for floats or long doubles: only doubles:
changing the suffixes of -1.0 and -2.0 above to -1.0f and -2.0f (or -1.0L and
-2.0L) results in valid generated code.

------------------
Output from gcc -v:

COLLECT_GCC=g++-11
COLLECT_LTO_WRAPPER=/home/bob/libexec/gcc/x86_64-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc/configure -v --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/home/bob/
--enable-checking=release --enable-languages=c,c++ --disable-multilib
--program-suffix=-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210426 (experimental) (GCC) 


Command line to trigger bug: g++-11 --std=c++20 bugtest.cpp -o test

Compiler output:
/tmp/ccmrd0Wr.s: Assembler messages:
/tmp/ccmrd0Wr.s:106: Error: symbol
`_ZZ3foovENKUl1TIXT_EEE_clILdffffffff00000000EEEDaS0_' is already defined

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

end of thread, other threads:[~2021-07-27  8:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27  1:33 [Bug c++/100279] New: Invalid generated assembly for NTTP lambda with negative double value bobmiller at nvidia dot com
2021-04-27  4:58 ` [Bug c++/100279] " bobmiller at nvidia dot com
2021-04-27  5:01 ` bobmiller at nvidia dot com
2021-04-27  5:22 ` [Bug c++/100279] [ICE in trunk] ICE caused by negative double NTTP. Error: Two symbols with same comdat_group are not linked by the same_comdat_group list bobmiller at nvidia dot com
2021-04-27 18:42 ` ppalka at gcc dot gnu.org
2021-07-27  8:08 ` pinskia 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).