Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

C++  Module 1 – Start here: toolchains, compiling and first programs

Reading C++ compiler errors and fixing old code

Read GCC and Clang error messages from the first line to the note that explains them, fix ten common beginner errors, and modernise pre-standard C++ code.

  • Beginner
  • 20 minutes
  • Examples run with Clang 21.0.0, GCC 16.2.0 and Python 3.14.8
  • By MySmartCoPilot
Free lesson, Pro answers: 20 minutes
Free: the whole lesson. With a pass: the model answers to its 2 interview questions.

What you will learn

  • Read an error message from its first line to the note that explains it
  • Fix the ten most common beginner errors
  • Find the real mistake when an error points at the wrong line or guesses the wrong name
  • Find your own line in a long template error and read the first error in it
  • Recognise pre-standard code (iostream.h, conio.h, void main) and modernise it

Before you start

What you’ll learn · Before you start

What you will learn

  • Read an error message from its first line to the note that explains it
  • Fix the ten most common beginner errors
  • Find the real mistake when an error points at the wrong line or guesses the wrong name
  • Find your own line in a long template error and read the first error in it
  • Recognise pre-standard code (iostream.h, conio.h, void main) and modernise it

Before you start

On this page

One missing line, #include <vector>, made Clang 21 print four errors and GCC 16 three. A compiler error is a report with a fixed shape: where the problem is, how serious it is, what the compiler expected, and often a suggestion. Read the first error first, from its location to the note: lines under it, because one mistake often produces several errors and only the first one is reliable.

Below are the parts of a message, the ten errors that beginners meet most, the long errors that Code written once for any type, such as std::sort or std::vector. The compiler writes the code for the types a program uses when it uses them, so a mistake can show up deep inside the library's own code. produce, and old textbook code that modern compilers reject, each with the exact words that Apple clang 21 and GCC 16 printed. The two compilers word the same problem differently, so knowing both helps when you search for a message.

An error message has five parts, and notes under it

This program uses cout without std:::

undeclared_cout.cpp C++ · undeclared_cout.cpp
#include <iostream>

int main() {
    cout << "Namaste\n";
}
The same mistake, as GCC 16 and Clang 21 report it Python · cout_session.py
from session import run

run("""
g++-16 -std=c++23 -Wall -Wextra -c undeclared_cout.cpp -o undeclared_cout.o
clang++ -std=c++23 -Wall -Wextra -c undeclared_cout.cpp -o undeclared_cout.o
""")

Output

$ g++-16 -std=c++23 -Wall -Wextra -c undeclared_cout.cpp -o undeclared_cout.o
undeclared_cout.cpp: In function 'int main()':
undeclared_cout.cpp:4:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    4 |     cout << "Namaste\n";
      |     ^~~~
      |     std::cout
In file included from undeclared_cout.cpp:1:
/opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/iostream:65:18: note: 'std::cout' declared here
   65 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
[exit status 1]
$ clang++ -std=c++23 -Wall -Wextra -c undeclared_cout.cpp -o undeclared_cout.o
undeclared_cout.cpp:4:5: error: use of undeclared identifier 'cout'; did you mean 'std::cout'?
    4 |     cout << "Namaste\n";
      |     ^~~~
      |     std::cout
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream:57:42: note: 'std::cout' declared here
   57 | extern _LIBCPP_EXPORTED_FROM_ABI ostream cout;
      |                                          ^
1 error generated.
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 cout_session.py

A report like this is called a diagnostic: A message a compiler prints about a program: an error, which stops the build, a warning, which does not, or a note that adds detail to the message above it. Each one starts with the file, the line and the column.. GCC printed the error as five pieces of information, one after the other:

  1. undeclared_cout.cpp: In function 'int main()': names the function the problem is in. Clang leaves this line out.
  2. undeclared_cout.cpp:4:5: is the file, the line and the column. Most editors jump there when you click it.
  3. error: is the severity. An error stops the build, a warning does not, and a note adds information to the message above it.
  4. 'cout' was not declared in this scope; did you mean 'std::cout'? is the message itself, here with a guess.
  5. The source line follows, with ^~~~ under the exact spot, and below it a fix-it: A line under a diagnostic's source line that shows the text to type, such as std::cout under cout. Clang and GCC print one when they can guess the change; check that it is what you meant before you apply it. line showing what to type: std::cout.

Then note: 'std::cout' declared here points into the <iostream> header, to show where the suggested name lives. Clang’s version of the same error reads use of undeclared identifier 'cout'; did you mean 'std::cout'?, with the same fix-it line. Different wording, the same information.

The diagram leaves out the function line, which Clang does not print, gives the guess a box of its own and adds the note, all in the order GCC printed them. Read a message in this order, and stop at the part that tells you what to change:

The six parts of a compiler error, top to bottom: location, severity, message, suggestion, source line with fix-it, and note.1. Whereundeclared_cout.cpp:4:5file : line : column2. How seriouserror stops the build,warning does not3. What went wrong'cout' was not declaredin this scope4. A guessdid you mean'std::cout'?5. The source line^~~~ under the spot,then the fix-it: std::cout6. note:'std::cout' declared here(in <iostream>)

One error message, part by part

Text description of the diagram

The diagram splits GCC 16's error for cout used without std:: into six numbered boxes, in two columns, in the order the compiler prints them.

  1. Where: undeclared_cout.cpp:4:5, the file, the line and the column.
  2. How serious: error, which stops the build, or warning, which does not.
  3. What went wrong: 'cout' was not declared in this scope.
  4. A guess: did you mean 'std::cout'?
  5. The source line, with ^~~~ under the spot and a fix-it line that shows std::cout.
  6. A note: 'std::cout' declared here, pointing into the <iostream> header.

Checkpoint

Check: The parts of an error message

  1. Question 1 of 2 GCC's error begins undeclared_cout.cpp:4:5:. What does the 5 tell you?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: The column, where cout starts on line 4

    A diagnostic starts with file:line:column. In undeclared_cout.cpp:4:5, line 4 is the line with cout, and column 5 is where cout begins. The ^~~~ under the source line marks the same spot, and most editors jump there when you click the location.

  2. Question 2 of 2 Under GCC's error for cout, a line reads note: 'std::cout' declared here and points into <iostream>. What is that note?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Extra information for the error above it, showing where the suggested name is declared

    error stops the build, warning does not, and note adds information to the message above it. Here the note shows where std::cout is declared, which backs up the fix-it line: write std::cout.

One missing include, four errors: fix the first one first

One mistake can produce a cascade. This program uses std::vector but never includes <vector>:

missing_vector.cpp C++ · missing_vector.cpp
#include <cstdio>

int main() {
    std::vector<int> runs{4, 6, 1};
    std::printf("%zu\n", runs.size());
}
Four errors from one missing line Python · vector_session.py
from session import run

# All the errors first, then only the first one.
run("""
clang++ -std=c++23 -Wall -Wextra -c missing_vector.cpp -o missing_vector.o
g++-16 -std=c++23 -Wall -Wextra -c missing_vector.cpp -o missing_vector.o
clang++ -std=c++23 -ferror-limit=1 -c missing_vector.cpp -o missing_vector.o
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -c missing_vector.cpp -o missing_vector.o
missing_vector.cpp:4:10: error: no member named 'vector' in namespace 'std'
    4 |     std::vector<int> runs{4, 6, 1};
      |          ^~~~~~
missing_vector.cpp:4:20: error: expected '(' for function-style cast or type construction
    4 |     std::vector<int> runs{4, 6, 1};
      |                 ~~~^
missing_vector.cpp:4:22: error: use of undeclared identifier 'runs'
    4 |     std::vector<int> runs{4, 6, 1};
      |                      ^~~~
missing_vector.cpp:5:26: error: use of undeclared identifier 'runs'
    5 |     std::printf("%zu\n", runs.size());
      |                          ^~~~
4 errors generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c missing_vector.cpp -o missing_vector.o
missing_vector.cpp: In function 'int main()':
missing_vector.cpp:4:10: error: 'vector' is not a member of 'std'
    4 |     std::vector<int> runs{4, 6, 1};
      |          ^~~~~~
missing_vector.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <cstdio>
  +++ |+#include <vector>
    2 | 
missing_vector.cpp:4:17: error: expected primary-expression before 'int'
    4 |     std::vector<int> runs{4, 6, 1};
      |                 ^~~
missing_vector.cpp:5:26: error: 'runs' was not declared in this scope
    5 |     std::printf("%zu\n", runs.size());
      |                          ^~~~
[exit status 1]
$ clang++ -std=c++23 -ferror-limit=1 -c missing_vector.cpp -o missing_vector.o
missing_vector.cpp:4:10: error: no member named 'vector' in namespace 'std'
    4 |     std::vector<int> runs{4, 6, 1};
      |          ^~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 vector_session.py

Clang 21 printed four errors: no member named 'vector' in namespace 'std' on line 4, then expected '(' for function-style cast or type construction, and twice use of undeclared identifier 'runs'. Only the first is the mistake. Once std::vector is unknown, the declaration of runs fails, and every later use of runs fails with it. GCC 16 printed three errors, and its first one came with the exact cure: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'. Adding that one line removes every error.

Step through Clang’s four errors in the order it printed them, and watch each one follow from the one before it:

Interactive · step by step Four errors from one missing line Step through Clang's four errors in the order it printed them. Each one follows from the one before it.
Four errors from one missing line, step 5 of 5. Showing 1: #include <cstdio>, 4: std::vector<int> runs (a vector of 3 runs), 5: runs.size(), Add #include <vector>, 4:10 no member 'vector' (gone), 4:20 expected '(' (gone), 4:22 undeclared 'runs' (gone), 5:26 undeclared 'runs' (gone). In focus: Add #include <vector>.thenthen1: #include <cstdio>no <vector> here4: std::vector<int> runsa vector of 3 runs5: runs.size()Add #include <vector>the cure in GCC's note4:10 no member 'vector'gone4:20 expected '('gone4:22 undeclared 'runs'gone5:26 undeclared 'runs'gone

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. The first error. Clang reads line 4 and stops at column 10: namespace std has no member named vector, because the file includes only <cstdio>. This is the mistake.
  2. A knock-on error. With std::vector unknown, std::vector<int> is no longer a type, so Clang tries to read the line as an expression and fails at column 20: expected '('.
  3. A name never declared. The declaration failed, so runs was never declared, and its name at column 22 is a use of undeclared identifier.
  4. The same cause again. Line 5 uses runs again and fails in the same way, at column 26. Four errors, one mistake.
  5. One line fixes all four. GCC's note named the cure: add #include <vector>. With that line, both compilers build the file without a word, and the program prints 3.

Here is the same file with that one line added, built by both compilers with the same warning flags:

missing_vector.cpp with #include <vector> C++ · missing_vector_fixed.cpp
#include <cstdio>
#include <vector>

int main() {
    std::vector<int> runs{4, 6, 1};
    std::printf("%zu\n", runs.size());
}
One line added: no errors, no warnings Python · vector_fixed_session.py
from session import run

# missing_vector.cpp with the one line that GCC's note asked for, built and run with both compilers.
run("""
clang++ -std=c++23 -Wall -Wextra missing_vector_fixed.cpp -o missing_vector_fixed && ./missing_vector_fixed
g++-16 -std=c++23 -Wall -Wextra missing_vector_fixed.cpp -o missing_vector_fixed && ./missing_vector_fixed
""")

Output

$ clang++ -std=c++23 -Wall -Wextra missing_vector_fixed.cpp -o missing_vector_fixed && ./missing_vector_fixed
3
$ g++-16 -std=c++23 -Wall -Wextra missing_vector_fixed.cpp -o missing_vector_fixed && ./missing_vector_fixed
3

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 vector_fixed_session.py

Neither compiler printed a word, and both programs printed 3, the number of values in runs.

So read the first error, fix it, and compile again. Later errors may disappear, or they may change. Both compilers can stop early for you: -fmax-errors=1 for GCC and -ferror-limit=1 for Clang show only the first error. The last command of the session shows Clang’s version, which ends with fatal error: too many errors emitted, stopping now [-ferror-limit=]. Clang stops after 20 errors by default; GCC has no limit unless you set one.

Key idea

Only the first error is sure to be your mistake: the errors after it often follow from it. Fix the first one, compile again, and read what is left.

Checkpoint

Check: Fixing the first error first

  1. Question 1 of 2 Clang printed four errors for missing_vector.cpp: no member named 'vector' in namespace 'std' at 4:10, then expected '(' at 4:20, then use of undeclared identifier 'runs' at 4:22 and at 5:26. Which one do you fix?

    Choose one answer.

    A hint

    Ask which error could have caused the others.

    Show the answer: Question 1 of 2

    Answer: The first, because nothing included <vector>

    The later errors follow from the first: with std::vector unknown, runs is never declared, so every line that uses runs fails as well. Adding #include <vector> removes all four, and the program prints 3.

  2. Question 2 of 2 Which option makes GCC show only the first error?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: -fmax-errors=1

    GCC's option is -fmax-errors=1 and Clang's is -ferror-limit=1; with either, only the first error is shown. Clang stops after 20 errors by default, and GCC has no limit unless you set one.

The line in the message is not always the line to fix

A compiler reports a problem where it notices it, which can be after the mistake. One program misses a semicolon, the other a closing brace:

Two mistakes at the end of a line

Missing ; · missing_semicolon.cpp

#include <iostream>

int main() {
    int marks = 92
    std::cout << marks << '\n';
}

Missing } · missing_brace.cpp

#include <iostream>

int main() {
    for (int over = 1; over <= 3; ++over) {
        std::cout << "Over " << over << '\n';

    std::cout << "Innings over\n";
}
Where the compilers report them Python · lines_session.py
from session import run

run("""
clang++ -std=c++23 -Wall -Wextra -c missing_semicolon.cpp -o missing_semicolon.o
g++-16 -std=c++23 -Wall -Wextra -c missing_semicolon.cpp -o missing_semicolon.o
clang++ -std=c++23 -Wall -Wextra -c missing_brace.cpp -o missing_brace.o
g++-16 -std=c++23 -Wall -Wextra -c missing_brace.cpp -o missing_brace.o
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -c missing_semicolon.cpp -o missing_semicolon.o
missing_semicolon.cpp:4:19: error: expected ';' at end of declaration
    4 |     int marks = 92
      |                   ^
      |                   ;
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c missing_semicolon.cpp -o missing_semicolon.o
missing_semicolon.cpp: In function 'int main()':
missing_semicolon.cpp:5:5: error: expected ',' or ';' before 'std'
    5 |     std::cout << marks << '\n';
      |     ^~~
missing_semicolon.cpp:4:9: warning: unused variable 'marks' [-Wunused-variable]
    4 |     int marks = 92
      |         ^~~~~
[exit status 1]
$ clang++ -std=c++23 -Wall -Wextra -c missing_brace.cpp -o missing_brace.o
missing_brace.cpp:8:2: error: expected '}'
    8 | }
      |  ^
missing_brace.cpp:3:12: note: to match this '{'
    3 | int main() {
      |            ^
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c missing_brace.cpp -o missing_brace.o
missing_brace.cpp: In function 'int main()':
missing_brace.cpp:8:2: error: expected '}' at end of input
    8 | }
      |  ^
missing_brace.cpp:3:12: note: to match this '{'
    3 | int main() {
      |            ^
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 lines_session.py

Clang pointed at the right place, line 4, column 19, with expected ';' at end of declaration and a fix-it line showing the ;. GCC reported expected ',' or ';' before 'std' on line 5, because it only knew the declaration had not ended when it reached the next word, std. GCC then added a knock-on warning, unused variable 'marks', because the broken declaration swallowed the line that used marks. When the reported line looks fine, look at the end of the line above it.

A missing closing brace is reported even further away, at the end of the file. Both compilers reported line 8, the last line, with expected '}' (Clang) or expected '}' at end of input (GCC), and both added note: to match this '{' pointing at line 3, the brace of main. Yet the brace that is missing closes the for loop on line 4: the closing brace on line 8 was taken as the end of the loop, which left main open. The compiler can only tell you that braces do not balance, not which one you forgot, so check the indentation of each block.

Step through how the braces of missing_brace.cpp pair up, and see why the report lands on line 8 and its note on line 3:

Interactive · step by step Where a missing brace is reported, and where it belongs Step through how the braces of missing_brace.cpp pair up. Each closing brace closes the nearest block still open.
Where a missing brace is reported, and where it belongs, step 5 of 5. Showing 3: int main() { (main: still open), 4: for (…) { (loop: closed by line 8), 5: std::cout << "Over ", 7: std::cout << … (read inside the loop), 8: }, end of the file, note: 3:12, the missing }, 8:2 expected '}'. In focus: the missing }.closes3: int main() {main: still open4: for (…) {loop: closed by line 85: std::cout << "Over "7: std::cout << …read inside the loop8: }end of the filenote: 3:12to match this '{'the missing }belongs after line 58:2 expected '}'both compilers

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. Two blocks open. Line 3 opens main with {, and line 4 opens the for loop with a second {. Two blocks are open.
  2. The loop's brace is missing. The loop's body was meant to end after line 5, but its } is missing, so line 7 is read as part of the loop as well.
  3. Line 8 closes the loop. A } closes the nearest block that is still open. The one on line 8 closes the loop of line 4, not main.
  4. The file ends. The file ends with main still open. Both compilers report it at line 8, column 2, the end of the input: expected '}'.
  5. The note and the real gap. The note points at line 3, the { of main, the block left open. The brace you forgot belongs after line 5, where the indentation of line 7 shows the loop should end.

Checkpoint

Check: Where the mistake really is

  1. Question 1 of 2 Why can a compiler report a mistake on the line after the one you must fix?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: It reports where it notices the problem, which can be at the next word it reads

    A compiler reports a problem where it notices it. For a missing semicolon GCC noticed at the next word, std, on line 5; for a missing closing brace both compilers noticed only at the end of the file. When the reported line looks fine, look at the end of the line above it.

  2. Question 2 of 2 For missing_brace.cpp, both compilers report expected '}' at line 8, the last line, with a note pointing at line 3, the { of main. Which brace is missing?

    Choose one answer.

    A hint

    Each closing brace closes the nearest block that is still open.

    Show the answer: Question 2 of 2

    Answer: The one that ends the for loop, after line 5

    The note names the block that is still open at the end, main, but the brace that is missing closes the for loop: the } on line 8 was taken as the loop's. A compiler can only tell you that the braces do not balance, so check the indentation of each block.

Ten common errors, and what each compiler calls them

Typing mistakes

Besides a missing ; or }, a common one is code copied from a PDF, a word processor or a chat app, where straight quotes have become curly ones:

Characters copied into code

Curly quotes · smart_quotes.cpp

#include <iostream>

int main() {
    std::cout << “Hello” << '\n';
}

Non-breaking space · non_breaking_space.cpp

#include <iostream>

int main() {
    int runs = 4;
    std::cout << runs << '\n';
}
What the compilers make of them Python · copied_session.py
from session import run

run("""
clang++ -std=c++23 -c smart_quotes.cpp -o smart_quotes.o
g++-16 -std=c++23 -c smart_quotes.cpp -o smart_quotes.o
clang++ -std=c++23 -c non_breaking_space.cpp -o non_breaking_space.o
g++-16 -std=c++23 -c non_breaking_space.cpp -o non_breaking_space.o
""")

Output

$ clang++ -std=c++23 -c smart_quotes.cpp -o smart_quotes.o
smart_quotes.cpp:4:18: error: unexpected character <U+201C>
    4 |     std::cout << “Hello” << '\n';
      |                  ^
smart_quotes.cpp:4:26: error: character <U+201D> not allowed in an identifier
    4 |     std::cout << “Hello” << '\n';
      |                        ^
smart_quotes.cpp:4:21: error: use of undeclared identifier 'Hello”'
    4 |     std::cout << “Hello” << '\n';
      |                   ^~~~~~
3 errors generated.
[exit status 1]
$ g++-16 -std=c++23 -c smart_quotes.cpp -o smart_quotes.o
smart_quotes.cpp:4:18: error: extended character “ is not valid in an identifier
    4 |     std::cout << “Hello” << '\n';
      |                  ^
smart_quotes.cpp:4:18: error: extended character ” is not valid in an identifier
smart_quotes.cpp: In function 'int main()':
smart_quotes.cpp:4:18: error: '“Hello”' was not declared in this scope
    4 |     std::cout << “Hello” << '\n';
      |                  ^~~~~~~
[exit status 1]
$ clang++ -std=c++23 -c non_breaking_space.cpp -o non_breaking_space.o
non_breaking_space.cpp:4:8: warning: treating Unicode character as whitespace [-Wunicode-whitespace]
    4 |     int runs = 4;
      |        ^
1 warning generated.
$ g++-16 -std=c++23 -c non_breaking_space.cpp -o non_breaking_space.o
non_breaking_space.cpp:4:5: error: extended character   is not valid in an identifier
    4 |     int runs = 4;
      |     ^
non_breaking_space.cpp: In function 'int main()':
non_breaking_space.cpp:4:5: error: 'int runs' was not declared in this scope
    4 |     int runs = 4;
      |     ^~~~~~~~
non_breaking_space.cpp:5:18: error: 'runs' was not declared in this scope
    5 |     std::cout << runs << '\n';
      |                  ^~~~
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 copied_session.py

Clang printed unexpected character <U+201C>, naming the Unicode code point of the left curly quote, then two knock-on errors. GCC printed extended character “ is not valid in an identifier. The cure is to retype the quotes as ". A non-breaking space, which looks exactly like a space, is the other usual suspect: GCC rejected it with the same message, while Clang treated it as a space and only warned treating Unicode character as whitespace.

Unicode Character Inspector Paste a line the compiler rejects to see every character's code point, including curly quotes and non-breaking spaces.

Names the compiler cannot find

Two ways to make a name unknown

Used before declared · use_before_declare.cpp

#include <iostream>

int main() {
    std::cout << area(3, 4) << '\n';
}

int area(int width, int height) {
    return width * height;
}

Missing <algorithm> · sort_without_algorithm.cpp

#include <iostream>
#include <vector>

int main() {
    std::vector<int> runs{4, 6, 1};
    std::sort(runs.begin(), runs.end());
    std::cout << runs.front() << '\n';
}
One error on both, one error on Clang only Python · names_session.py
from session import run

run("""
clang++ -std=c++23 -Wall -Wextra -c use_before_declare.cpp -o use_before_declare.o
g++-16 -std=c++23 -Wall -Wextra -c use_before_declare.cpp -o use_before_declare.o
g++-16 -std=c++23 -Wall -Wextra sort_without_algorithm.cpp -o sort_without_algorithm && ./sort_without_algorithm
clang++ -std=c++23 -Wall -Wextra sort_without_algorithm.cpp -o sort_without_algorithm
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -c use_before_declare.cpp -o use_before_declare.o
use_before_declare.cpp:4:18: error: use of undeclared identifier 'area'
    4 |     std::cout << area(3, 4) << '\n';
      |                  ^~~~
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c use_before_declare.cpp -o use_before_declare.o
use_before_declare.cpp: In function 'int main()':
use_before_declare.cpp:4:18: error: 'area' was not declared in this scope
    4 |     std::cout << area(3, 4) << '\n';
      |                  ^~~~
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra sort_without_algorithm.cpp -o sort_without_algorithm && ./sort_without_algorithm
1
$ clang++ -std=c++23 -Wall -Wextra sort_without_algorithm.cpp -o sort_without_algorithm
sort_without_algorithm.cpp:6:10: error: no member named 'sort' in namespace 'std'
    6 |     std::sort(runs.begin(), runs.end());
      |          ^~~~
1 error generated.
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 names_session.py

A function must be declared before the line that calls it. In the first file area is defined after main, so both compilers stop at the call: use of undeclared identifier 'area' (Clang) and 'area' was not declared in this scope (GCC). Move the function above main, or put a declaration such as int area(int width, int height); before it.

The second file is the dangerous kind. It calls std::sort without #include <algorithm>. GCC 16 compiled it and the program printed 1, because one of the headers it did include pulls in std::sort on its own. Clang 21, with a different standard library, stopped with no member named 'sort' in namespace 'std'. Code like this builds on one computer and fails on the next, or on an online judge. Include the header of everything you use; the reference pages for each function name its header.

Types and calls

Values and calls that do not fit

Wrong type · wrong_type.cpp

#include <iostream>

int main() {
    int overs = "20";
    std::cout << overs << '\n';
}

Wrong arguments · wrong_arguments.cpp

#include <iostream>

int area(int width, int height) {
    return width * height;
}

int main() {
    std::cout << area(3) << '\n';
}

Missing () · member_without_call.cpp

#include <iostream>
#include <string>

int main() {
    std::string name = "Asha";
    std::cout << name.size << '\n';
}
Three mistakes, two compilers Python · calls_session.py
from session import run

run("""
clang++ -std=c++23 -Wall -Wextra -c wrong_type.cpp -o wrong_type.o
g++-16 -std=c++23 -Wall -Wextra -c wrong_type.cpp -o wrong_type.o
clang++ -std=c++23 -Wall -Wextra -c wrong_arguments.cpp -o wrong_arguments.o
g++-16 -std=c++23 -Wall -Wextra -c wrong_arguments.cpp -o wrong_arguments.o
clang++ -std=c++23 -Wall -Wextra -c member_without_call.cpp -o member_without_call.o
g++-16 -std=c++23 -Wall -Wextra -c member_without_call.cpp -o member_without_call.o
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -c wrong_type.cpp -o wrong_type.o
wrong_type.cpp:4:9: error: cannot initialize a variable of type 'int' with an lvalue of type 'const char[3]'
    4 |     int overs = "20";
      |         ^       ~~~~
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c wrong_type.cpp -o wrong_type.o
wrong_type.cpp: In function 'int main()':
wrong_type.cpp:4:17: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
    4 |     int overs = "20";
      |                 ^~~~
      |                 |
      |                 const char*
[exit status 1]
$ clang++ -std=c++23 -Wall -Wextra -c wrong_arguments.cpp -o wrong_arguments.o
wrong_arguments.cpp:8:18: error: no matching function for call to 'area'
    8 |     std::cout << area(3) << '\n';
      |                  ^~~~
wrong_arguments.cpp:3:5: note: candidate function not viable: requires 2 arguments, but 1 was provided
    3 | int area(int width, int height) {
      |     ^    ~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c wrong_arguments.cpp -o wrong_arguments.o
wrong_arguments.cpp: In function 'int main()':
wrong_arguments.cpp:8:22: error: too few arguments to function 'int area(int, int)'
    8 |     std::cout << area(3) << '\n';
      |                  ~~~~^~~
wrong_arguments.cpp:3:5: note: declared here
    3 | int area(int width, int height) {
      |     ^~~~
[exit status 1]
$ clang++ -std=c++23 -Wall -Wextra -c member_without_call.cpp -o member_without_call.o
member_without_call.cpp:6:23: error: reference to non-static member function must be called; did you mean to call it with no arguments?
    6 |     std::cout << name.size << '\n';
      |                  ~~~~~^~~~
      |                           ()
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c member_without_call.cpp -o member_without_call.o
member_without_call.cpp: In function 'int main()':
member_without_call.cpp:6:15: error: invalid use of non-static member function 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
    6 |     std::cout << name.size << '\n';
      |     ~~~~~~~~~~^~~~~~~~~~~~
In file included from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/string:58,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/bits/locale_classes.h:43,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/bits/ios_base.h:43,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/ios:46,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/bits/ostream.h:43,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/ostream:42,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/iostream:43,
                 from member_without_call.cpp:1:
/opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/bits/basic_string.h:1187:7: note: declared here
 1187 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 calls_session.py

  • A string where a number is expected. int overs = "20"; gave cannot initialize a variable of type 'int' with an lvalue of type 'const char[3]' from Clang and invalid conversion from 'const char*' to 'int' [-fpermissive] from GCC. "20" is text; write 20. The [-fpermissive] tag only says which flag would turn this error into a warning. Never use that flag to make an error go away.
  • The wrong number of arguments. Clang said no matching function for call to 'area' and then, in a note, candidate function not viable: requires 2 arguments, but 1 was provided. GCC said too few arguments to function 'int area(int, int)' and pointed to the declaration. With overloaded functions the notes list every candidate and why each failed, so read them all.
  • A member function without its parentheses. name.size instead of name.size() gave Clang’s reference to non-static member function must be called; did you mean to call it with no arguments?, with a fix-it adding (). GCC’s message, invalid use of non-static member function, ran to a full line of template parameters and eight lines of In file included from. Skip that noise and keep the words that matter: an invalid use of size().

main must return int

void main() C++ · void_main.cpp
#include <iostream>

void main() {
    std::cout << "Hello\n";
}
Both compilers reject it Python · void_main_session.py
from session import run

run("""
clang++ -std=c++23 -Wall -Wextra -c void_main.cpp -o void_main.o
g++-16 -std=c++23 -Wall -Wextra -c void_main.cpp -o void_main.o
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -c void_main.cpp -o void_main.o
void_main.cpp:3:1: error: 'main' must return 'int'
    3 | void main() {
      | ^~~~
      | int
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c void_main.cpp -o void_main.o
void_main.cpp:3:1: error: '::main' must return 'int'
    3 | void main() {
      | ^~~~
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 void_main_session.py

Both compilers rejected it: 'main' must return 'int' (Clang, with a fix-it replacing void by int) and '::main' must return 'int' (GCC). The standard requires main to have the return type int. You do not have to write return 0; at its end: reaching the end of main returns 0.

All ten at a glance

Mistake Clang 21 says GCC 16 says
Missing ; expected ';' at end of declaration expected ',' or ';' before 'std' (on the next line)
Missing } expected '}' expected '}' at end of input
Curly quotes unexpected character <U+201C> extended character “ is not valid in an identifier
cout without std:: use of undeclared identifier 'cout'; did you mean 'std::cout'? 'cout' was not declared in this scope; did you mean 'std::cout'?
Function used before it is declared use of undeclared identifier 'area' 'area' was not declared in this scope
Missing #include <vector> no member named 'vector' in namespace 'std' 'vector' is not a member of 'std', with a note naming <vector>
Text assigned to an int cannot initialize a variable of type 'int' with an lvalue of type 'const char[3]' invalid conversion from 'const char*' to 'int'
Wrong number of arguments no matching function for call to 'area' too few arguments to function 'int area(int, int)'
name.size without () reference to non-static member function must be called invalid use of non-static member function
void main() 'main' must return 'int' '::main' must return 'int'

When a message in front of you matches a row of the table, the mistake is the one in its first column, whichever compiler printed it. Try three of the rows:

Checkpoint

Check: Ten common errors

  1. Question 1 of 3 sort_without_algorithm.cpp calls std::sort without #include <algorithm>. GCC 16 builds it and the program prints 1. Clang 21 refuses it: no member named 'sort' in namespace 'std'. What do you change?

    Choose one answer.

    Show the answer: Question 1 of 3

    Answer: Add #include <algorithm>, the header of std::sort

    Include the header of everything you use: the reference page of each function names its header. Code that leans on another header's includes builds on one computer and fails on the next.

  2. Question 2 of 3 Clang reports reference to non-static member function must be called for the second line. What is the fix?

    Read the code, then choose one answer.

    std::string name = "Asha";
    std::cout << name.size << '\n';
    Show the answer: Question 2 of 3

    Answer: Write name.size(), with the parentheses

    name.size names the member function; name.size() calls it and gives 4. GCC's message for the same line, invalid use of non-static member function, says the same thing in more words.

  3. Question 3 of 3 GCC's error invalid conversion from 'const char*' to 'int' [-fpermissive] ends with a flag in brackets. What does the bracket tell you?

    Choose one answer.

    Show the answer: Question 3 of 3

    Answer: Which flag would turn this error into a warning, which is not a fix

    int overs = "20"; puts text where a number belongs. The [-fpermissive] tag only says which flag would turn this error into a warning. Write 20.

Some messages point the wrong way

Suggestions and messages are the compiler’s best guess, and sometimes the guess is wrong. This program includes <iostream> but not <vector>:

No <vector>, but <iostream> C++ · vector_via_iostream.cpp
#include <iostream>

int main() {
    std::vector<int> runs{4, 6, 1};
    std::cout << runs.size() << '\n';
}
Two unhelpful errors Python · iostream_vector_session.py
from session import run

run("""
clang++ -std=c++23 -Wall -Wextra -c vector_via_iostream.cpp -o vector_via_iostream.o
g++-16 -std=c++23 -Wall -Wextra -c vector_via_iostream.cpp -o vector_via_iostream.o
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -c vector_via_iostream.cpp -o vector_via_iostream.o
vector_via_iostream.cpp:4:22: error: implicit instantiation of undefined template 'std::vector<int>'
    4 |     std::vector<int> runs{4, 6, 1};
      |                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__fwd/vector.h:22:7: note: template is declared here
   22 | class vector;
      |       ^
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -Wall -Wextra -c vector_via_iostream.cpp -o vector_via_iostream.o
vector_via_iostream.cpp: In function 'int main()':
vector_via_iostream.cpp:4:20: error: wrong number of template arguments (1, should be 2)
    4 |     std::vector<int> runs{4, 6, 1};
      |                    ^
In file included from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/ostream:45,
                 from /opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/iostream:43,
                 from vector_via_iostream.cpp:1:
/opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/format:3195:36: note: provided for 'template<class, class> class std::vector'
 3195 | template<typename, typename> class vector;
      |                                    ^~~~~~
vector_via_iostream.cpp:4:22: error: scalar object 'runs' requires one element in initializer
    4 |     std::vector<int> runs{4, 6, 1};
      |                      ^~~~
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 iostream_vector_session.py

With <iostream> included, neither compiler suggested #include <vector>. Clang said implicit instantiation of undefined template 'std::vector<int>' and GCC said wrong number of template arguments (1, should be 2), because each library’s <iostream> happens to declare std::vector without defining it. The messages describe a symptom, not the cause. When a standard type behaves strangely right after you start using it, check its #include first.

The old program later in this lesson gets another wrong guess: for an unknown cin, Clang suggested did you mean 'sin'?, the sine function, and GCC suggested getc for getch. A “did you mean” points at a name that is spelt alike, which is not always the name you meant.

Checkpoint

Check: Messages and guesses that mislead

  1. Question 1 of 2 For an unknown name cin, Clang 21 asked did you mean 'sin'?. What is the right fix?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: Write std::cin, because cin is in namespace std

    A "did you mean" suggestion is a name spelt like the unknown one. Here it was the sine function. The program meant the standard input stream, std::cin.

  2. Question 2 of 2 A file includes only <iostream> and declares std::vector<int> runs{4, 6, 1};. GCC says wrong number of template arguments (1, should be 2). What do you check first?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Whether the file includes <vector>

    With <iostream> included, neither compiler suggested #include <vector>, because each library's <iostream> happens to declare std::vector without defining it. When a standard type misbehaves right after you start using it, check its #include first.

A 114-line template error has one line of yours

Errors inside templates are long because the compiler shows how it got there. std::sort needs An object that marks a position in a container and can move on to the next element. begin() gives the first position, and end() the position just past the last element. that can jump to any position, which a std::list does not have:

Sorting a std::list C++ · sort_list.cpp
#include <algorithm>
#include <list>

int main() {
    std::list<int> scores{72, 45, 90};
    std::sort(scores.begin(), scores.end());
}
Questions asked of a long error Python · sort_list_session.py
from session import run

# The whole error is long, so each command asks a question of it: how many lines, how many errors, which lines name
# this file, and what the first error says.
run("""
clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | wc -l
clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -c "error:"
clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep "sort_list.cpp:"
clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -m 1 "error:"
g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | wc -l
g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -c "error:"
g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep "sort_list.cpp:"
g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -m 1 "error:"
""")

Output

$ clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | wc -l
     114
$ clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -c "error:"
4
$ clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep "sort_list.cpp:"
In file included from sort_list.cpp:1:
sort_list.cpp:6:10: note: in instantiation of function template specialization 'std::sort<std::__list_iterator<int, void *>>' requested here
In file included from sort_list.cpp:1:
sort_list.cpp:6:10: note: in instantiation of function template specialization 'std::sort<std::__list_iterator<int, void *>>' requested here
In file included from sort_list.cpp:1:
sort_list.cpp:6:10: note: in instantiation of function template specialization 'std::sort<std::__list_iterator<int, void *>>' requested here
In file included from sort_list.cpp:1:
sort_list.cpp:6:10: note: in instantiation of function template specialization 'std::sort<std::__list_iterator<int, void *>>' requested here
$ clang++ -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -m 1 "error:"
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/make_heap.h:37:31: error: invalid operands to binary expression ('std::__list_iterator<int, void *>' and 'std::__list_iterator<int, void *>')
$ g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | wc -l
      33
$ g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -c "error:"
1
$ g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep "sort_list.cpp:"
                 from sort_list.cpp:1:
sort_list.cpp:6:14:   required from here
$ g++-16 -std=c++23 -c sort_list.cpp -o sort_list.o 2>&1 | grep -m 1 "error:"
/opt/homebrew/Cellar/gcc/16.2.0/include/c++/16/bits/stl_algo.h:1914:50: error: no match for 'operator-' (operand types are 'std::_List_iterator<int>' and 'std::_List_iterator<int>')

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 sort_list_session.py

Rather than print it all, the session asks the output four questions with wc and grep. Clang 21 printed 114 lines with 4 errors, all inside <algorithm>, and each error has a note on this file: in instantiation of function template specialization 'std::sort<std::__list_iterator<int, void *>>' requested here. GCC 16 printed 33 lines with 1 error, no match for 'operator-' (operand types are 'std::_List_iterator<int>' and 'std::_List_iterator<int>'), preceded by required from here lines. To read such an error:

  1. Find your own file in it. Both compilers name your line in the chain: GCC with sort_list.cpp:6:14: required from here, Clang with a note on sort_list.cpp:6:10. That is the call to look at.
  2. Read the first error: line for the kind of failure. Clang’s invalid operands to binary expression and GCC’s no match for 'operator-' both say that subtracting two list iterators fails: std::sort wants iterators that can be subtracted, and list iterators cannot.
  3. Skip the candidates (reverse_iterator, move_iterator) unless the first two steps did not explain it.

The fix is scores.sort();, the list’s own member function, or a std::vector instead of a list.

Follow the three steps through the recorded output, one step at a time:

Interactive · stage by stage Reading the 114 lines of a template error Step through the error that std::sort on a std::list produced. Each step reads one thing from the recorded output.
Reading the 114 lines of a template error, step 5 of 5. Showing 114 lines from Clang, Find your own file, Read the first error:, Skip the candidates, Fix the call. In focus: Fix the call.114 lines from Clang4 errors, all in <algorithm>Find your own filesort_list.cpp, line 6Read the first error:list iterators subtractedSkip the candidatesunless still unclearFix the callscores.sort(), or a vector

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. The whole error. std::sort on a std::list made Clang 21 print 114 lines with 4 errors, all inside <algorithm>, and GCC 16 print 33 lines with 1 error. Reading them from the top explains the library, not your code.
  2. Your own line. Search the output for your file's name. GCC marks the call with sort_list.cpp:6:14: required from here, and Clang's notes name sort_list.cpp:6:10. Line 6 is the call to std::sort.
  3. What failed. The first error: line says what failed: Clang's invalid operands to binary expression and GCC's no match for 'operator-', both about two list iterators. std::sort needs to subtract iterators, and list iterators cannot be subtracted.
  4. The candidates. Notes about candidates such as reverse_iterator and move_iterator say why other functions did not fit either. Read them only if the first two steps left you unsure.
  5. The fix. Sort the list with its own member function, scores.sort();, or keep the scores in a std::vector. With std::ranges::sort instead, Clang's 22 lines end with the reason: the list is not a random_access_range.

Version note

New in GCC 16: C++ errors such as this one are printed as a tree, with indentation and bullet points (•) under the error. -fno-diagnostics-show-nesting or -fdiagnostics-plain-output restores the flat layout of earlier releases.

Constrained algorithms from C++20 give errors that name the requirement that failed. With std::ranges::sort(scores); instead, Clang printed 22 lines instead of 114, and its notes give the reason itself: because 'std::list<int> &' does not satisfy 'random_access_range'. GCC’s version grew to 51 lines, from 33 for std::sort, but the session finds the same requirement in its tree: required for the satisfaction of 'random_access_range<_Range>'.

The same mistake with std::ranges::sort C++ · sort_list_ranges.cpp
#include <algorithm>
#include <list>

int main() {
    std::list<int> scores{72, 45, 90};
    std::ranges::sort(scores);
}
A constrained algorithm explains itself Python · ranges_session.py
from session import run

# Clang's error in full; GCC's is longer, so the session counts its lines and finds the requirement it names.
run("""
clang++ -std=c++23 -c sort_list_ranges.cpp -o sort_list_ranges.o
g++-16 -std=c++23 -c sort_list_ranges.cpp -o sort_list_ranges.o 2>&1 | wc -l
g++-16 -std=c++23 -c sort_list_ranges.cpp -o sort_list_ranges.o 2>&1 | grep "satisfaction of 'random_access_range"
""")

Output

$ clang++ -std=c++23 -c sort_list_ranges.cpp -o sort_list_ranges.o
sort_list_ranges.cpp:6:5: error: no matching function for call to object of type 'const __sort'
    6 |     std::ranges::sort(scores);
      |     ^~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/ranges_sort.h:64:3: note: candidate template ignored: constraints not satisfied [with _Range = std::list<int> &, _Comp = ranges::less, _Proj = identity]
   64 |   operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
      |   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/ranges_sort.h:61:13: note: because 'std::list<int> &' does not satisfy 'random_access_range'
   61 |   template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
      |             ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__ranges/concepts.h:116:59: note: because 'iterator_t<std::list<int, std::allocator<int>> &>' (aka '__list_iterator<int, void *>') does not satisfy 'random_access_iterator'
  116 | concept random_access_range = bidirectional_range<_Tp> && random_access_iterator<iterator_t<_Tp>>;
      |                                                           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/concepts.h:219:36: note: because 'derived_from<_ITER_CONCEPT<std::__list_iterator<int, void *>>, random_access_iterator_tag>' evaluated to false
  219 |     bidirectional_iterator<_Ip> && derived_from<_ITER_CONCEPT<_Ip>, random_access_iterator_tag> &&
      |                                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__concepts/derived_from.h:27:24: note: because 'is_base_of_v<std::random_access_iterator_tag, std::bidirectional_iterator_tag>' evaluated to false
   27 | concept derived_from = is_base_of_v<_Bp, _Dp> && is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
      |                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/ranges_sort.h:57:3: note: candidate function template not viable: requires at least 2 arguments, but 1 was provided
   57 |   operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -c sort_list_ranges.cpp -o sort_list_ranges.o 2>&1 | wc -l
      51
$ g++-16 -std=c++23 -c sort_list_ranges.cpp -o sort_list_ranges.o 2>&1 | grep "satisfaction of 'random_access_range"
          • required for the satisfaction of 'random_access_range<_Range>' [with _Range = std::__cxx11::list<int, std::allocator<int> >&]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 ranges_session.py

Checkpoint

Check: Reading long template errors

  1. Question 1 of 2 GCC printed 33 lines for sort_list.cpp. Which of these lines points at the code you should change?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: sort_list.cpp:6:14: required from here

    Find your own file in the error first. GCC names the call with required from here, and Clang with a note on sort_list.cpp:6:10. Then read the first error: line for the kind of failure.

  2. Question 2 of 2 With std::ranges::sort(scores); instead of std::sort, Clang printed 22 lines instead of 114. What do its notes say?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: That std::list<int> & does not satisfy random_access_range

    Constrained algorithms from C++20 name the requirement that failed. Clang's error for std::ranges::sort shrank from 114 lines to 22, and its notes end with the requirement the list fails, random_access_range. GCC's grew from 33 lines to 51, but its tree names the same requirement.

Pre-standard textbook code fails one layer at a time

Many older books and lab manuals show programs like this one:

A program written for a pre-standard compiler

As printed · old_textbook.cpp

#include <iostream.h>
#include <conio.h>

void main() {
    clrscr();
    int a, b;
    cout << "Enter two numbers: ";
    cin >> a >> b;
    cout << "Sum = " << a + b;
    getch();
}

Headers fixed · old_textbook_step2.cpp

#include <iostream>

void main() {
    clrscr();
    int a, b;
    cout << "Enter two numbers: ";
    cin >> a >> b;
    cout << "Sum = " << a + b;
    getch();
}
One layer of errors at a time Python · old_code_session.py
from session import run

# The book's version stops at the first line. With the headers fixed, grep lists every error that is left.
run("""
clang++ -std=c++23 -c old_textbook.cpp -o old_textbook.o
g++-16 -std=c++23 -c old_textbook.cpp -o old_textbook.o
clang++ -std=c++23 -c old_textbook_step2.cpp -o old_textbook_step2.o 2>&1 | grep "error:"
g++-16 -std=c++23 -c old_textbook_step2.cpp -o old_textbook_step2.o 2>&1 | grep "error:"
""")

Output

$ clang++ -std=c++23 -c old_textbook.cpp -o old_textbook.o
old_textbook.cpp:1:10: fatal error: 'iostream.h' file not found
    1 | #include <iostream.h>
      |          ^~~~~~~~~~~~
1 error generated.
[exit status 1]
$ g++-16 -std=c++23 -c old_textbook.cpp -o old_textbook.o
old_textbook.cpp:1:10: fatal error: iostream.h: No such file or directory
    1 | #include <iostream.h>
      |          ^~~~~~~~~~~~
compilation terminated.
[exit status 1]
$ clang++ -std=c++23 -c old_textbook_step2.cpp -o old_textbook_step2.o 2>&1 | grep "error:"
old_textbook_step2.cpp:3:1: error: 'main' must return 'int'
old_textbook_step2.cpp:4:5: error: use of undeclared identifier 'clrscr'
old_textbook_step2.cpp:6:5: error: use of undeclared identifier 'cout'; did you mean 'std::cout'?
old_textbook_step2.cpp:7:5: error: use of undeclared identifier 'cin'; did you mean 'sin'?
old_textbook_step2.cpp:7:5: error: reference to overloaded function could not be resolved; did you mean to call it?
old_textbook_step2.cpp:8:5: error: use of undeclared identifier 'cout'; did you mean 'std::cout'?
old_textbook_step2.cpp:9:5: error: use of undeclared identifier 'getch'
$ g++-16 -std=c++23 -c old_textbook_step2.cpp -o old_textbook_step2.o 2>&1 | grep "error:"
old_textbook_step2.cpp:3:1: error: '::main' must return 'int'
old_textbook_step2.cpp:4:5: error: 'clrscr' was not declared in this scope
old_textbook_step2.cpp:6:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
old_textbook_step2.cpp:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
old_textbook_step2.cpp:9:5: error: 'getch' was not declared in this scope; did you mean 'getc'?

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 old_code_session.py

Both compilers stopped at line 1 with a fatal error: An error after which the compiler stops at once and checks nothing more, such as a header file that does not exist: 'iostream.h' file not found., which ends the compilation at once: 'iostream.h' file not found (Clang) and iostream.h: No such file or directory followed by compilation terminated. (GCC). Fixing the headers only uncovers the next layer: with <iostream> in place and <conio.h> removed, Clang printed seven errors and GCC five, for void main, clrscr, getch, and cout and cin without std::. None of these features belongs to standard C++:

Old code Why it fails Modern C++
#include <iostream.h> Not a standard header; the standard’s name is <iostream> #include <iostream>
#include <conio.h>, clrscr(), getch() Not in standard C or C++; Microsoft’s runtime still has a <conio.h> with _getch(), but the usual Linux and macOS toolchains have no such header Leave the screen alone; to pause, std::cin.get() waits for Enter
void main() main must return int int main()
cout, cin without std:: Standard names live in namespace: A named scope that groups names so that they cannot collide: the standard library's names are in namespace std, so std::count and a program's own count are two different names. More in “C++ program structure, naming and formatting” std std::cout, std::cin
int a, b; read without a check Bad input leaves the values unchanged or 0 if (!(std::cin >> a >> b))

The rewrite compiles without a warning under -Wall -Wextra -Wpedantic on both compilers:

The same program in standard C++ C++ · old_textbook_modern.cpp
#include <iostream>

int main() {
    int a = 0;
    int b = 0;
    std::cout << "Enter two numbers: ";
    if (!(std::cin >> a >> b)) {
        std::cerr << "Please type two whole numbers.\n";
        return 1;
    }
    std::cout << "Sum = " << a + b << '\n';
}
Built with every warning, given 3 and 4 Python · modern_session.py
from session import run

run("""
clang++ -std=c++23 -Wall -Wextra -Wpedantic old_textbook_modern.cpp -o old_textbook_modern && echo "3 4" | ./old_textbook_modern
g++-16 -std=c++23 -Wall -Wextra -Wpedantic old_textbook_modern.cpp -o old_textbook_modern && echo "3 4" | ./old_textbook_modern
""")

Output

$ clang++ -std=c++23 -Wall -Wextra -Wpedantic old_textbook_modern.cpp -o old_textbook_modern && echo "3 4" | ./old_textbook_modern
Enter two numbers: Sum = 7
$ g++-16 -std=c++23 -Wall -Wextra -Wpedantic old_textbook_modern.cpp -o old_textbook_modern && echo "3 4" | ./old_textbook_modern
Enter two numbers: Sum = 7

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 modern_session.py

With 3 4 on standard input it printed Enter two numbers: Sum = 7 with both compilers. Step through the whole repair, from the book’s version to the one that runs:

Interactive · stage by stage Old textbook code, one layer of errors at a time Step through what the two compilers did with the book's program, and with each fix.
Old textbook code, one layer of errors at a time, step 6 of 6. Showing As the book prints it, Stops at line 1, Headers fixed, The next layer, Standard C++, Built and run. In focus: Built and run.As the book prints itiostream.h, conio.hStops at line 1fatal error: no iostream.hHeaders fixed<iostream>, no <conio.h>The next layerClang 7 errors, GCC 5Standard C++int main(), std:: namesBuilt and run3 4 gives Sum = 73 4

The drawing shows the whole scene; its 6 steps are listed below.

Every step as text
  1. As printed. old_textbook.cpp includes <iostream.h> and <conio.h>, declares void main(), and calls clrscr() and getch(), as many older books and lab manuals do.
  2. A fatal error. Both compilers stop at line 1: 'iostream.h' file not found (Clang) and iostream.h: No such file or directory (GCC). A fatal error ends the compilation, so nothing else is reported yet.
  3. Headers fixed. With <iostream> in place of <iostream.h> and <conio.h> removed, the compilers get past the first line and check the rest of the file.
  4. The next layer. Now Clang prints seven errors and GCC five, for void main, clrscr, getch, and cout and cin written without std::.
  5. Standard C++. The rewrite has int main(), std::cout and std::cin, checks the read with if (!(std::cin >> a >> b)), and leaves the screen alone. It builds without a warning under -Wall -Wextra -Wpedantic.
  6. Built and run. Given 3 4 on standard input, the builds of both compilers print Enter two numbers: Sum = 7.

College labs

If your lab or textbook uses Turbo C++, or programs written for it, expect exactly these lines: iostream.h, conio.h, clrscr(), getch() and void main(). For lab records and exams, write what the syllabus asks for; for everything else, including placement tests and online judges, write the standard version shown here, which every current compiler accepts.

Checkpoint

Check: Modernising pre-standard code

  1. Question 1 of 2 Why did both compilers stop at line 1 of old_textbook.cpp, #include <iostream.h>, and report nothing else?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: A missing header file is a fatal error, which ends the compilation at once

    A fatal error, such as a header file that does not exist, ends the compilation, so the rest of the file is not checked yet. That is why fixing old code goes one layer of errors at a time.

  2. Question 2 of 2 The book's program ends with getch(); to keep the window open until a key is pressed. If you need a pause at all, what does standard C++ use?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: std::cin.get(), which waits for Enter

    <conio.h>, clrscr() and getch() are not standard C or C++. Leave the screen alone, and if the program must pause, std::cin.get() waits for Enter.

Five steps that work on any error

The sections above come down to one routine. It works with either compiler and with any error, and it starts from the smallest output that can still show the mistake:

  1. Compile again with only the first error showing (-fmax-errors=1 or -ferror-limit=1).
  2. Go to the file, line and column, and also read the line above it.
  3. Read the message word by word, then every note: under it. In a template error, find your own file first.
  4. Look for a fix-it line, but check that it is what you meant.
  5. If the message still makes no sense, try the other compiler: Clang and GCC often explain the same mistake in different words. Search for the message with your own names and file paths taken out.

Here are the five steps on the missing <vector> from the start of this lesson, using what each compiler printed:

Interactive · stage by stage The five steps, on the missing <vector> Step through the routine on the file of the second section, using what the two compilers printed for it.
The five steps, on the missing <vector>, step 5 of 5. Showing 1. Only the first error, 2. Go to line and column, 3. Message, then notes, 4. Look for a fix-it, 5. Try the other compiler. In focus: 5. Try the other compiler.1. Only the first error-ferror-limit=12. Go to line and column4:10, and the line above3. Message, then notesno member named 'vector'4. Look for a fix-itnone from Clang here5. Try the other compilerGCC's note names <vector>

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. Only the first error. Compile again with clang++ -ferror-limit=1: it prints only no member named 'vector' in namespace 'std', then stops with too many errors emitted.
  2. Go to the spot. Go to missing_vector.cpp:4:10, the word vector, and read the line above it too. Line 3, int main() {, is fine, and the top of the file includes only <cstdio>.
  3. Read every word. Namespace std has no member named vector here: nothing the file includes declares it. Clang adds no note to this error.
  4. Look for a fix-it. Clang shows no fix-it line for this error, so there is nothing to check yet. For cout without std:: it did show one, std::cout, which was what that program meant.
  5. Ask the other compiler. GCC 16's note says 'std::vector' is defined in header '<vector>' and shows the fix-it +#include <vector> under line 1. Add it and compile again.

Checkpoint

Check: A routine for any error

  1. One question You have shown only the first error, gone to its line and the line above, and read the message and every note. It still makes no sense. What is the next step of the routine?

    Choose one answer.

    Show the answer: One question

    Answer: Look for a fix-it, then try the other compiler

    After the first three steps comes the fix-it, checked against what you meant, and then the other compiler: Clang and GCC often word the same mistake differently. Then search for the message with your own names and paths taken out.

Practice: fix three broken programs

Make each of these compile with -std=c++23 -Wall -Wextra -Werror on your compiler, fixing the cause each time rather than hiding the message: missing_semicolon.cpp (it should print 92), wrong_arguments.cpp (make it print the area of a 3 by 4 rectangle, 12) and use_before_declare.cpp (it should print 12). Then take old_textbook.cpp and rewrite it without looking at the version above.

Check yourself

With the programs fixed, answer the questions below. They begin with the idea you know least, get harder as you get them right, and explain every answer, right or wrong:

Practice that adapts to you

Practise this lesson

18 questions about 8 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 18 Which kind of diagnostic stops the build?

    Choose one answer.

    Show the answer: Question 1 of 18

    Answer: An error

    error stops the build, warning does not, and note adds information to the message above it. The severity is the word right after the location.

  2. Question 2 of 18 Clang's message for cout without std:: has no In function 'int main()': line. What does Clang leave out compared with GCC?

    Choose one answer.

    Show the answer: Question 2 of 18

    Answer: Only the line that names the function

    The two compilers word the message differently, use of undeclared identifier 'cout' against 'cout' was not declared in this scope, but both give the location, the severity, the message, a guess and the fix-it. Only GCC adds the name of the function first.

  3. Question 3 of 18 Clang reports four errors for a program that uses std::vector without #include <vector>. What do you do first?

    Choose one answer.

    Show the answer: Question 3 of 18

    Answer: Fix the first error, by adding the include, and compile again

    Only the first error is the mistake. The other three ("use of undeclared identifier 'runs'" and the like) follow from it, so they disappear once <vector> is included. -fpermissive never fixes a missing header.

  4. Question 4 of 18 For missing_vector.cpp, which compiler's first error came with a note that named the header to include?

    Choose one answer.

    Show the answer: Question 4 of 18

    Answer: GCC 16: 'std::vector' is defined in header '<vector>'

    GCC printed three errors, and its first came with the exact cure: a note naming <vector> and a fix-it line that adds #include <vector>. Adding that one line removes every error of both compilers.

  5. Question 5 of 18 GCC reports "expected ',' or ';' before 'std'" on line 5, and line 5 looks correct. Where is the mistake most likely to be?

    Choose one answer.

    Show the answer: Question 5 of 18

    Answer: At the end of line 4, which is missing its semicolon

    GCC only knew that the declaration on line 4 had not ended when it met the next word, std, on line 5. Clang reported the same mistake on line 4 itself, with a fix-it showing the missing ;.

  6. Question 6 of 18 When the line an error names looks correct, where do you look next?

    Choose one answer.

    Show the answer: Question 6 of 18

    Answer: At the end of the line above it

    The reported line is where the compiler noticed the problem. A missing semicolon shows on the next line in GCC, and a missing closing brace at the end of the file.

  7. Question 7 of 18 What return type must main have in standard C++?

    Choose one answer.

    Show the answer: Question 7 of 18

    Answer: int

    The standard requires main to have the return type int. You do not have to write return 0; at its end: reaching the end of main returns 0.

  8. Question 8 of 18 Clang says no matching function for call to 'area' and GCC too few arguments to function 'int area(int, int)'. Which change makes the program print the area of a 3 by 4 rectangle?

    Read the code, then choose one answer.

    int area(int width, int height) {
        return width * height;
    }
    
    int main() {
        std::cout << area(3) << '\n';
    }
    Show the answer: Question 8 of 18

    Answer: Call area(3, 4)

    Clang's note said candidate function not viable: requires 2 arguments, but 1 was provided. With overloaded functions the notes list every candidate and why each failed, so read them all.

  9. Question 9 of 18 Clang reports unexpected character <U+201C> for a line you copied from a PDF. What is wrong?

    Choose one answer.

    Show the answer: Question 9 of 18

    Answer: The quotes around the text are curly; retype them as straight quotes

    Copying from a PDF, a word processor or a chat app can turn straight quotes into curly ones. Clang names the code point, <U+201C>; GCC says extended character “ is not valid in an identifier. Retype the quotes.

  10. Question 10 of 18 What is a "did you mean" suggestion in a compiler error?

    Choose one answer.

    Show the answer: Question 10 of 18

    Answer: A name spelt like the unknown one, which may not be the name you meant

    Suggestions are the compiler's best guess, and sometimes the guess is wrong: a "did you mean" points at a name that is spelt alike, which is not always the name you meant.

  11. Question 11 of 18 For getch();, GCC 16 asked did you mean 'getc'?. What do you do with that line?

    Choose one answer.

    Show the answer: Question 11 of 18

    Answer: Remove it, or use std::cin.get() if the program needs a pause

    The suggestion is a name spelt alike. The line came from a pre-standard compiler, and standard C++ has no getch(); std::cin.get() is the standard way to wait for Enter.

  12. Question 12 of 18 A call to std::sort produces 114 lines of errors inside <algorithm>. What should you look for first?

    Choose one answer.

    Show the answer: Question 12 of 18

    Answer: The line in your own file, named by "required from here" (GCC) or "in instantiation of ... requested here" (Clang)

    Template errors show the chain of instantiations that led to the failure. Your own call is in that chain, and the first error line then says what the call's arguments lacked: list iterators cannot be subtracted.

  13. Question 13 of 18 GCC's first error for sort_list.cpp is no match for 'operator-' (operand types are 'std::_List_iterator<int>' and 'std::_List_iterator<int>'). What does it tell you?

    Choose one answer.

    Show the answer: Question 13 of 18

    Answer: std::sort subtracts iterators, which list iterators cannot do, so std::sort cannot sort a list

    Clang's invalid operands to binary expression and GCC's no match for 'operator-' both say that subtracting two list iterators fails: std::sort wants iterators that can jump to any position, and list iterators cannot.

  14. Question 14 of 18 Which of these lines are not standard C++? Choose every one.

    Choose every answer that is right.

    Show the answer: Question 14 of 18

    Answer:

    • void main()
    • #include <iostream.h>
    • clrscr();

    <iostream.h> is not one of the headers the standard lists, main must return int, and clrscr() is not declared by any standard header. <iostream> and int main() are standard, and every current compiler accepts them.

  15. Question 15 of 18 The standard version reads the two numbers like this. What happens when the input is three 4?

    Read the code, then choose one answer.

    int a = 0;
    int b = 0;
    std::cout << "Enter two numbers: ";
    if (!(std::cin >> a >> b)) {
        std::cerr << "Please type two whole numbers.\n";
        return 1;
    }
    Show the answer: Question 15 of 18

    Answer: The read fails, so the message goes to standard error and the program ends with status 1

    Reading without a check leaves the values unchanged or 0 when the input is bad. if (!(std::cin >> a >> b)) tests the read itself, so a bad answer gets a message instead of a wrong sum.

  16. Question 16 of 18 What is the first step of the routine for any error?

    Choose one answer.

    Show the answer: Question 16 of 18

    Answer: Compile again with only the first error showing

    The routine: show only the first error; go to its file, line and column, and read the line above; read the message and every note; check any fix-it; then try the other compiler.

  17. Question 17 of 18 A fix-it line suggests a change. What does step 4 of the routine ask you to do with it?

    Choose one answer.

    Show the answer: Question 17 of 18

    Answer: Check that it is what you meant before you apply it

    Look for a fix-it line, but check that it is what you meant: std::cout for cout was right, sin for cin was not.

  18. Question 18 of 18 A build of a project prints 40 errors; the first is in report.cpp at line 12, column 8. Only Clang is installed. What do you do first?

    Choose one answer.

    Show the answer: Question 18 of 18

    Answer: Rebuild with -ferror-limit=1, then go to report.cpp:12:8 and read the line above it too

    Most of the 40 errors may follow from the first, so cut the output to it, go to report.cpp:12:8, read the line above it, then the message and every note. A second compiler is the last step, not the first.

Interview questions

When a build prints twenty errors, why do you fix the first one first? (warm-up)

Because the later errors are often consequences of the first. A compiler that meets a mistake tries to carry on, so a missing #include makes a name unknown, every declaration that uses the name fails, and every use of those declarations fails again. In this lesson one missing <vector> gave Clang four errors and GCC three, and a single missing semicolon gave GCC a knock-on warning about an unused variable. Fixing the first error and compiling again removes most of the cascade, and what remains is real. The first error is also the one whose location is most trustworthy, although even it can point one line after the mistake, as a missing semicolon does with GCC.

An interviewer will usually push further. Two follow-up questions come next: choose the answer you would give, and the feedback explains what each choice gets right and what it misses.

Checkpoint

Interview round: two follow-up questions

  1. Question 1 of 2 An interviewer goes on: for the same missing <vector>, Clang printed four errors and GCC three. Why do the counts differ, and which count matters?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: Each compiler carries on differently after the first error, so the knock-on errors differ; only the first, the same mistake in both, matters

    A compiler that meets a mistake tries to carry on, and Clang and GCC carry on in different ways, so the errors after the first differ. The first error is where both agree, and fixing it removes the rest.

  2. Question 2 of 2 And a harder case: a 117-line main gives one error, expected '}' at end of input at the last line, with a note on the { of main. How do you find the missing brace quickly?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Check the indentation of each block inside main, to find the block whose closing brace is missing

    A missing } is reported at the end of the file, with a note on the outermost block left open. The compiler cannot know which brace you forgot, but the indentation shows where each block was meant to end.

Model answers open with any pass: ₹79 for 1 week ($2.99), one payment that never renews.

  1. Fresher to senior

    After a one-line change, the build prints 300 lines of template errors from deep inside the standard library. Walk through how you find the real cause in a few minutes, and how you would make such errors shorter for the whole team.

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Fresher to mid

    Code that builds on your GCC laptop fails on a colleague's Mac with "no member named 'sort' in namespace 'std'". Explain why it built for you at all, how you prevent this kind of bug, and what else differs between the two toolchains.

    Model answer, Pro. First step and follow-ups

Key takeaways

  • A diagnostic tells you where (file:line:column), how serious (error, warning, note), what, and often how to fix it; read the notes under it too.
  • Fix the first error and compile again: one missing #include produced four errors with Clang.
  • The reported line can be after the mistake: a missing ; shows on the next line in GCC, and a missing } at the end of the file.
  • “Did you mean” is a guess (Clang offered sin for cin), and a missing header can produce an unrelated-looking error; GCC compiled std::sort without <algorithm> where Clang did not.
  • In long template errors, find your own file’s line, then read the first error:; constrained std::ranges algorithms say which requirement failed. GCC 16 shows such errors as a tree.
  • iostream.h, conio.h, clrscr(), getch() and void main() are not standard C++; write <iostream>, std:: names and int main().

Terms in this lesson

diagnostic
A message a compiler prints about a program: an error, which stops the build, a warning, which does not, or a note that adds detail to the message above it. Each one starts with the file, the line and the column.
fatal error
An error after which the compiler stops at once and checks nothing more, such as a header file that does not exist: 'iostream.h' file not found.
fix-it
A line under a diagnostic's source line that shows the text to type, such as std::cout under cout. Clang and GCC print one when they can guess the change; check that it is what you meant before you apply it.

Corrections

  • Corrected: with std::ranges::sort, Clang's error was shorter but GCC's was longer than for std::sort; what both gained is the name of the requirement that failed.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.