[Bug c++/115296] New: CTAD fails
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115296 Bug ID: 115296 Summary: CTAD fails Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- The following code compiles fine with clang and msvc, but fails with gcc. https://godbolt.org/z/e4dP7rzar ``` #include template using array_view = std::span; void fun(std::span s) { [[maybe_unused]] auto _1 = std::span{s}; [[maybe_unused]] auto _2 = array_view{s}; } ``` Error: ``` In file included from :1: /opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span: In function 'void fun(std::span)': /opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:450:5: error: size '18446744073709551615' of array exceeds maximum object size '9223372036854775807' 450 | span(_Type(&)[_ArrayExtent]) -> span<_Type, _ArrayExtent>; | ^~~~ /opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:450:10: error: size '18446744073709551615' of array exceeds maximum object size '9223372036854775807' 450 | span(_Type(&)[_ArrayExtent]) -> span<_Type, _ArrayExtent>; | ^~ :8:44: error: class template argument deduction failed: 8 | [[maybe_unused]] auto _2 = array_view{s}; |^ :8:44: error: call of overloaded 'span(std::span&)' is ambiguous /opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:464:5: note: candidate: 'std::span(_Range&&)-> span >::type> requires __is_deducible (array_view, std::span)()))&>)())>::type, 18446744073709551615>) [with _Range = span&; typename remove_reference >::type = int; ranges::range_reference_t<_Range&> = int&]' 464 | span(_Range &&) | ^~~~ /opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:54:11: note: candidate: 'span(std::span<_Type, 18446744073709551615>)-> std::span<_Type, 18446744073709551615> [with T = int]' 54 | class span; | ^~~~ /opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:225:7: note: candidate: 'span(const std::span<_Type, 18446744073709551615>&)-> std::span<_Type, 18446744073709551615> [with T = int]' 225 | span(const span&) noexcept = default; | ^~~~ Compiler returned: 1 ```
[Bug c++/107652] New: c++20 gccchoses incorrect operator== overload
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107652 Bug ID: 107652 Summary: c++20 gccchoses incorrect operator== overload Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- In C++20 gcc will chose the incorrect overload for this code. The overload should be ambiguous (see msvc). https://godbolt.org/z/rox1z1Txa ``` namespace N { struct C; struct B; struct A { bool fun(A, B, C); bool operator==(A const&) const; bool operator!=(A const&) const; }; struct B : A {}; struct C : A { bool operator==(C const&) const; bool operator!=(C const&) const; C(const B&); }; } // namespace N namespace N { bool A::fun(A a, B b, C c) { return b == c; } } // namespace N ```
[Bug c++/98750] does not detect dead code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98750 --- Comment #2 from Tiago Macarios --- Correct. I was expecting a warning there.
[Bug c++/98750] New: does not detect dead code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98750 Bug ID: 98750 Summary: does not detect dead code Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- for the following code gcc will not detect that f() is never called. msvc detects this correctly. https://godbolt.org/z/Y5n78v ``` void f(); void _(int num) { switch (num) { case 1: break; f(); } } ```
[Bug c++/98543] New: fails to diagnose unnecessary functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98543 Bug ID: 98543 Summary: fails to diagnose unnecessary functions Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- clang diagnoses unnecessary functions, gcc fails to: https://godbolt.org/z/vvErGh static void f() { [[maybe_unused]] auto var = }
[Bug c++/98520] New: nodiscard not diagnosed in comma operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98520 Bug ID: 98520 Summary: nodiscard not diagnosed in comma operator Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- https://godbolt.org/z/13j51h struct [[nodiscard]] S{}; void f(); void _() { f(), S{}; }
[Bug c++/96871] New: Fails to parse templated constructor in template class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96871 Bug ID: 96871 Summary: Fails to parse templated constructor in template class Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- Both clang and MSVC compile the below fine - gcc fails. https://godbolt.org/z/hfPdKT #include template struct S { template S(Arg&&... arg); }; :6:11: error: expected ')' before '&&' token 6 | S(Arg&&... arg); | ~ ^~ | )
[Bug c++/90473] New: gcc does not call function in comma operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 Bug ID: 90473 Summary: gcc does not call function in comma operator Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- In the code below gcc should call f() prios to calling b(), but that does not happen. https://godbolt.org/z/e245vi void f(); void b(void* p = (f(), nullptr)); void z() { b(); }
[Bug c++/89880] New: compiles code that should not be compiled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89880 Bug ID: 89880 Summary: compiles code that should not be compiled Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- https://godbolt.org/z/4cbr24 void f() { int a; int b; bool c; if ((!((int(bool(a))) ^ (int(bool(b && !(c))) {} }
[Bug c++/88162] New: GCC does not accept non-type template parameters of class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88162 Bug ID: 88162 Summary: GCC does not accept non-type template parameters of class type Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- Looking at http://eel.is/c++draft/temp.arg.nontype I would think that the code below is C++17 complaint. GCC thinks this is only available in 2a mode. clang compiles it fine in c++17 mode. https://godbolt.org/z/PGoXwX template struct id { using type = T; }; template class T> id f( T ) { }; constexpr struct zero_type { template constexpr operator T () const { return {}; } } zero; template class T> using nttp_t = typename decltype( f(T()) )::type; template struct int_constant {}; template struct char_constant {}; template struct long_constant {}; template struct voidp_constant {}; void g( nttp_t, nttp_t, nttp_t, nttp_t ) { }
[Bug c++/88118] GCC keeps unnecessary calls to new
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88118 --- Comment #6 from Tiago Macarios --- Related clang bug: https://bugs.llvm.org/show_bug.cgi?id=39731
[Bug c++/88118] New: GCC keeps unnecessary calls to new
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88118 Bug ID: 88118 Summary: GCC keeps unnecessary calls to new Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- With the code below clang generates: main: # @main mov eax, 2 ret GCC will get to the correct result, but will keep the new calls: main: sub rsp, 8 mov edi, 24 calloperator new(unsigned long) mov edi, 24 calloperator new(unsigned long) mov edi, 24 calloperator new(unsigned long) mov eax, 2 add rsp, 8 ret https://godbolt.org/z/Q3nV2x namespace { struct Node { int value{}; Node* left{}; Node* right{}; constexpr Node(int i=0) noexcept : value(i) {}; }; auto constexpr left = ::left; auto constexpr right = ::right; template constexpr Node* traverse(T np, TP... paths) noexcept { return (np ->* ... ->* paths); } } int main() { Node* const root = new Node{0}; root->left = new Node{1}; root->left->right = new Node{2}; Node* const node = traverse(root, left, right); return node->value; }
[Bug c++/87699] New: Implement CWG 1512
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699 Bug ID: 87699 Summary: Implement CWG 1512 Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- As per http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3478.html the below should not compile. https://godbolt.org/z/mOpxau bool foo(int* bar) { return bar > 0; }
[Bug c++/85552] Adding curly braces to the declaration of a std::unique_ptr to a forward declared class breaks compilation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85552 --- Comment #4 from Tiago Macarios --- Related clang bug: https://bugs.llvm.org/show_bug.cgi?id=39363
[Bug c++/87660] New: Fail to compile unique_ptr of incomplete tyoe
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87660 Bug ID: 87660 Summary: Fail to compile unique_ptr of incomplete tyoe Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- https://godbolt.org/z/zvJQ4F For the following code GCC will fail to compile the {} and the nullptr initializes. #include struct foo; struct bar { #if defined(DEFAULT) std::unique_ptr m_; #elif defined(UNIFORM) std::unique_ptr m_{}; #else std::unique_ptr m_ = nullptr; #endif }; I would think this is a bug as per http://eel.is/c++draft/unique.ptr#4.sentence-3
[Bug c++/87179] New: duplicate extern "C" functions in different namespaces not flagged as an error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87179 Bug ID: 87179 Summary: duplicate extern "C" functions in different namespaces not flagged as an error Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- Code below compiles in GCC, but is discarded by clang. namespace A { extern "C" int g() { return 1; } } namespace B { extern "C" int g() { return 1; } // ill-formed, the function g with C language linkage has two definitions } clang error: :6:18: error: redefinition of 'g' extern "C" int g() { return 1; } // ill-formed, the function g with C language linkage has two definitions ^ :2:18: note: previous definition is here extern "C" int g() { return 1; } ^ 1 error generated. Compiler returned: 1 example is a copy and paste from the standard http://eel.is/c++draft/dcl.link#6
[Bug c++/87152] New: internal compiler error: in tsubst_copy, at cp/pt.c:15484
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87152 Bug ID: 87152 Summary: internal compiler error: in tsubst_copy, at cp/pt.c:15484 Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- https://godbolt.org/z/RnO6a- #include #include #include template constexpr int int_from_bits() { constexpr auto a = std::array{bits...}; int sum = 0; for (int index = 0; bool const b : a) { sum += b ? exp2(index) : 0; } return sum; } int j = int_from_bits(); : In instantiation of 'constexpr int int_from_bits() [with bool ...bits = {false, false, true}]': :19:40: required from here :13:25: internal compiler error: in tsubst_copy, at cp/pt.c:15486 13 | sum += b ? exp2(index) : 0; | ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1
[Bug libstdc++/86433] New: Shouldn't non const hashers also be allowed?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86433 Bug ID: 86433 Summary: Shouldn't non const hashers also be allowed? Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: tiagomacarios at gmail dot com Target Milestone: --- https://godbolt.org/g/Z1cqm9 #include struct my_hash { std::size_t operator() (int const&) /*const*/ { return {}; // ~ } }; std::unordered_set temp; Shouldn't non-const hashers also be allowed? http://eel.is/c++draft/hash.requirements#2