Bug 60402 - [DR 1395] const overload with variadics declared ambiguous according to standard
Summary: [DR 1395] const overload with variadics declared ambiguous according to standard
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-03-03 19:31 UTC by Nate McNamara
Modified: 2022-06-30 14:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-06-11 00:00:00


Attachments
(unpreprocessed) source (179 bytes, text/plain)
2014-03-03 19:31 UTC, Nate McNamara
Details
preprocessed source (8.02 KB, text/plain)
2014-03-03 19:47 UTC, Nate McNamara
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nate McNamara 2014-03-03 19:31:28 UTC
Created attachment 32255 [details]
(unpreprocessed) source

$ g++ -v
Reading specs from /ms/dist/fsf/PROJ/gcc/4.8.1/.exec/@sys/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/ms/dist/fsf/PROJ/gcc/4.8.1/.exec/@sys/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: //ms/dev/fsf/gcc/4.8.1/src/gcc-4.8.1/configure --prefix=//ms/dist/fsf/PROJ/gcc/4.8.1/.exec/x86_64.linux.2.6.glibc.2.3 --exec-prefix=//ms/dist/fsf/PROJ/gcc/4.8.1/.exec/x86_64.linux.2.6.glibc.2.3 --disable-checking --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-gmp=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3 --with-mpfr=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3 --with-mpc=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3 --enable-linker-build-id --with-cloog=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3 --with-isl=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 4.8.1 (GCC)
$ g++ -std=c++11 ambiguous.cpp
ambiguous.cpp: In instantiation of 'void f(const char*, T ...) [with T = {int}]':
ambiguous.cpp:12:14:   required from here
ambiguous.cpp:7:51: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [enabled by default]
   f(const_cast<char*>(s), std::forward<T>(args)...);
                                                   ^
ambiguous.cpp:6:6: note: candidate 1: void f(const char*, T ...) [with T = {int}]
 void f(const char* s, T... args) {
      ^
ambiguous.cpp:3:6: note: candidate 2: void f(char*, ...)
 void f(char* s, ...) {}
      ^
Comment 1 Nate McNamara 2014-03-03 19:47:06 UTC
Created attachment 32256 [details]
preprocessed source
Comment 2 Daniel Krügler 2014-03-03 20:31:10 UTC
No, this is not related to bug 58156. According to the current core language of C++11, the code is indeed ambiguous.

There exists currently a core language issue to fix that, see

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1395
Comment 3 Andrew Pinski 2021-12-04 07:35:05 UTC
[Moved to DR at the November, 2016 meeting.]

(In reply to Daniel Krügler from comment #2)
> No, this is not related to bug 58156. According to the current core language
> of C++11, the code is indeed ambiguous.
> 
> There exists currently a core language issue to fix that, see
> 
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1395

Hmm, but this example is still rejected in both GCC and clang (and MSVC) but accepted for ICC. The example in both defect reports is done correctly with GCC and all.