[Bug c++/96976] New: g++ reports "call of overloaded '...' is ambiguous" when universal reference is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96976 Bug ID: 96976 Summary: g++ reports "call of overloaded '...' is ambiguous" when universal reference is used Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: igor.chorazewicz at intel dot com Target Milestone: --- Following code compiles fine on clang++ and gcc 11 but fails on all older gcc versions I tested (9.3.0, 9.2.1, 10.0.1). #include template void f(int &&a, Args&&... args) { } template ::type> void f(K&& k, Args&&... args) { } int main() { f(1, 2); return 0; } The error is: prog.cc: In function 'int main()': prog.cc:14:11: error: call of overloaded 'f(int, int)' is ambiguous 14 | f(1, 2); | ^ prog.cc:4:6: note: candidate: 'void f(int&&, Args&& ...) [with Args = {int}]' 4 | void f(int &&a, Args&&... args) | ^ prog.cc:9:6: note: candidate: 'void f(K&&, Args&& ...) [with K = int; Args = {int}; = int]' 9 | void f(K&& k, Args&&... args) Note that if I remove the dummy enable_if, the program compiles fine. It also compiles if there is no template parameter pack (Args...)
[Bug c++/96976] g++ reports "call of overloaded '...' is ambiguous" when universal reference is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96976 --- Comment #2 from Igor Chorazewicz --- (In reply to Jonathan Wakely from comment #1) > Fixed on trunk by r11-1571 > > It's also fixed on the gcc-10 branch by r10-8343 Do you plan to backport it to older gcc versions? Also, do you by any chance, have any ideas how to workaround it for now?
[Bug c++/92869] New: g++ wrongly reports aggregate type as not-aggregate (when explicitly defaulted ctors are added)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92869 Bug ID: 92869 Summary: g++ wrongly reports aggregate type as not-aggregate (when explicitly defaulted ctors are added) Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: igor.chorazewicz at intel dot com Target Milestone: --- The following code, when compiled with -std=c++17 results in "0" being printed. The correct behavior is to print "1". Removing ctors fixes the issue, however, accordingly to the standard, explicitly defaulted ctors are allowed for an aggregate. #include #include #include template struct A { A() = default; A(const A &) = default; A(A &&) = default; T arr[N]; }; int main() { std::cout << std::is_aggregate>::value; }
[Bug c++/92869] C++17 wrongly reports aggregate type as not-aggregate (when explicitly defaulted ctors are added)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92869 --- Comment #2 from Igor Chorazewicz --- Hm, from what I thought C++11 (not sure about C++14 but probably also) allows ctors to be explicitly defaulted for aggregates. See C++11 [dcl.init.aggr]. Consider the following code: #include #include #include template struct A { A() = default; A(const A &) = default; A(A &&) = default; T arr[N]; }; int main() { A a {{1,2,3}}; } This code compiles with g++ 9.2 for -std=c++11, -std=c++14, std=c++17 (but not for -std=c++2a) and fails to compile for g++ 10 for all standards
[Bug c++/92869] [10 Regression] C++17 wrongly reports aggregate type as not-aggregate (when explicitly defaulted ctors are added)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92869 --- Comment #5 from Igor Chorazewicz --- Ok, but P1816R0 talks about argument deduction - in my example I specify all template arguments for A, so should this fail? Moreover, for g++ 10 and g++ 9.2 even the following, non-template code fails for -std=c++2a struct A { A() = default; A(const A &) = default; A(A &&) = default; int arr[3]; }; int main() { A a = {{1,2,3}}; }
[Bug c++/88661] New: No brace ellision performed when aggregate is initialized inside of struct
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88661 Bug ID: 88661 Summary: No brace ellision performed when aggregate is initialized inside of struct Product: gcc Version: 5.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: igor.chorazewicz at intel dot com Target Milestone: --- The following code produces "error: array must be initialized with a brace-enclosed initializer": struct array { int data[3]; }; struct X { array a = {1,2,3}; };
[Bug c/85902] New: -Wstringop-truncation false-positive
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85902 Bug ID: 85902 Summary: -Wstringop-truncation false-positive Product: gcc Version: 8.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: igor.chorazewicz at intel dot com Target Milestone: --- Observed in fedora 28 - gcc 8.1.1 20180502 (Red Hat 8.1.1-1). Consider the following code: int main(int argc, char *argv[]) { char dst[10]; strncpy(dst, argv[0], sizeof(dst)); if (dst[sizeof(dst) - 1] == '\0') printf("%s\n", dst); return 0; } When compiled with '-Wall -O2' gcc gives following warning: warning: 'strncpy' specified bound 10 equals destination size [-Wstringop-truncation] I think this code handles truncation correctly and gcc should not emit this warning. Warning persists even if we change the code to the following (which makes buffer overflow impossible): int main(int argc, char *argv[]) { char dst[10]; strncpy(dst, argv[0], sizeof(dst)); if (dst[sizeof(dst) - 1] == '\0') printf("%s\n", dst); else dst[sizeof(dst) - 1] = '\0'; return 0; } In my project, this warning is triggered from following function, which is attempt to implement safer strcpy: static inline int util_safe_strcpy(char *dst, const char *src, size_t max_length) { if (max_length == 0) return -1; strncpy(dst, src, max_length); return dst[max_length - 1] == '\0' ? 0 : -1; } Moreover -Wstringop-truncation is not documented to be in -Wall: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
[Bug c++/88365] New: -Wsign-conversion ignores implicit conversion
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88365 Bug ID: 88365 Summary: -Wsign-conversion ignores implicit conversion Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: igor.chorazewicz at intel dot com Target Milestone: --- Consider following code, compiled with -Wsign-conversion: #include template struct wrapper { T t; operator T() { return t; } T get() { return t; } }; int main() { int a[10]; int* x { a } ; wrapper y{2}; std::cout << (x + y); // warning } It produces "warning: conversion to 'long int' from 'long unsigned int' may change the sign of the result". If y is of type "long unsigned int", there is no warning. Moreover when I explicitly call y.get() there is also no warning: std::cout << (x + y.get()); // ok