Compile-Time Errors: Errors that occur when you violate the rules of writing syntax are known as Compile-Time errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by the compiler and thus are known as compile-time errors.
Most frequent Compile-Time errors are:
- Missing Parenthesis (})
- Printing the value of variable without declaring it
- Missing semicolon (terminator)
Below is an example to demonstrate Compile-Time Error:
error: expected ';' before '}' token
Run-Time Errors: Errors which occur during program execution(run-time) after successful compilation are called run-time errors. One of the most common run-time error is division by zero also known as Division error. These types of error are hard to find as the compiler doesn’t point to the line at which the error occurs.
For more understanding run the example given below.
warning: division by zero [-Wdiv-by-zero] div = n/0;
In the given example, there is Division by zero error. This is an example of run-time error i.e errors occurring while running the program.
The Differences between Compile-Time and Run-Time Error are:
|These are the syntax errors which are detected by the compiler.||These are the errors which are not detected by the compiler and produce wrong results.|
|They prevent the code from running as it detects some syntax errors.||They prevent the code from complete execution.|
|It includes syntax errors such as missing of semicolon(;), misspelling of keywords and identifiers etc.||It includes errors such as dividing a number by zero, finding square root of a negative number etc.|
- Difference between Compile Time and Execution Time address binding
- Difference between Compile Time and Load Time address Binding
- Difference between Compile-time and Run-time Polymorphism in Java
- Difference between Seek Time and Transfer Time in Disk Scheduling
- Difference between Load Time and Execution Time address binding
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
- Difference between Arrival Time and Burst Time in CPU Scheduling
- Difference between Time Sharing OS and Real-Time OS
- Difference between Transfer Time and Disk Access Time in Disk Scheduling
- Difference between Seek Time and Disk Access Time in Disk Scheduling
- Difference between Hard real time and Soft real time system
- How to avoid Compile Error while defining Variables
- Difference between Firm Real-time Tasks and Soft Real-time Tasks
- Difference between Periodic and Sporadic Real-time Tasks
- Difference between Sporadic and Aperiodic Real-time Tasks
- Difference between Periodic and Aperiodic Real-time Tasks
- Difference between Seek Time and Rotational Latency in Disk Scheduling
- Difference between Rotational Latency and Transfer Time in Disk Scheduling
- Difference between Relative and Absolute Deadline of Real-time Task
- Difference between Delay and Deadline Constraint in Real-time System
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.