1. 2
  1.  

  2. 15

    Since the beginning clang was generating better error messages

    GCC got better since though

    1. 10

      Yes, the clang team made a real effort to produce helpful messages about a decade ago. I think there’s still scope for improvement, though, I frequently get errors where the line with the actual error is pointed at by the seventh of twelve messages.

      1. 10

        While it may be true that Clang generally produces better error messages,

        Through this simple test, clang seems generating more user-friendly error message than gcc

        … is not a good conclusion to draw from a single example.

        1. 4

          Garbage in, garbage out. If you run the same test with

          template< typename A, typename B >
          struct Pair {
              A a;
              B b;
          };
          

          in place of std::pair, you get

          pair.cc: In function ‘int main()’:
          pair.cc:14:28: error: use of deleted function ‘Pair<std::basic_string<char>, A>::Pair()’
               Pair< std::string, A > p;
                                      ^
          pair.cc:8:8: note: ‘Pair<std::basic_string<char>, A>::Pair()’ is implicitly deleted because the default definition would be ill-formed:
           struct Pair {
                  ^~~~
          pair.cc:8:8: error: no matching function for call to ‘A::A()’
          pair.cc:4:5: note: candidate: A::A(int)
               A( int ) { }
               ^
          pair.cc:4:5: note:   candidate expects 1 argument, 0 provided
          pair.cc:3:8: note: candidate: constexpr A::A(const A&)
           struct A {
                  ^
          pair.cc:3:8: note:   candidate expects 1 argument, 0 provided
          pair.cc:3:8: note: candidate: constexpr A::A(A&&)
          pair.cc:3:8: note:   candidate expects 1 argument, 0 provided
          

          This is a problem with the STL, not gcc.

          1. 1

            MSVC (at least 2015 and older) has some really awful error messages, worse than gcc.

            Something along the lines of

            SomeThingClass(const SomeThignClass& other) {
            

            returned something about the “return type is int by default” behavior from old C not being allowed anymore in VS2015. clang helpfully suggested: no template named 'SomeThignClass'; did you mean 'SomeThingClass'?