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

            Bug ID: 116368
           Summary: placeholder type deduction bug
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: delacroix777 at proton dot me
  Target Milestone: ---

The exact version of GCC:
gcc version 14.2.0 (Rev1, Built by MSYS2 project) - the latest version
package mingw-w64-ucrt-x86_64-gcc

The system type:
Windows 11 64-bit 23H2

The options given when GCC was configured/built:
"-Wall","-Wextra","-pedantic-errors","-std=c++23","-O2","-s","-static"

***

The problem is that the compiler does not generate any errors or warnings when
compiling the following code:

#include <iostream>

template <typename T, typename U> void foo(T t, U u)
{
    auto a = t, b = u;
    std::cout << a << ' ' << b;
}

int main()
{
    foo(42, 3.14);
}

It seems to me that this is a violation of the ISO C++ (9.2.9.6.1):

" If the init-declarator-list contains more than one init-declarator, they
shall all form declarations of variables. The type of each declared variable is
determined by placeholder type deduction, and if the type that replaces the
placeholder type is not the same in each deduction, the program is ill-formed.
"

Other compilers give an error in this case.

Reply via email to