---
title: "What are the types of errors that can occur during compilation?"  
description: "What are the types of errors that can occur during compilation?"  
author: "Utpal Vishwas"  
published: 2023-04-07  
updated: 2023-04-24  
canonical: https://www.mindstick.com/forum/157729/what-are-the-types-of-errors-that-can-occur-during-compilation  
category: "compiler design"  
tags: ["computer hardware", "computer system"]  
reading_time: 3 minutes  

---

# What are the types of errors that can occur during compilation?

What are the types of [errors](https://answers.mindstick.com/qa/116170/fresh-fir-against-gandhis-in-national-herald-case-cover-up-for-ed-s-own-errors) that can occur during [compilation](https://www.mindstick.com/interview/358/which-is-the-first-level-of-compilation-in-the-dot-net-languages)?

## Replies

### Reply by Aryan Kumar

During compilation, several types of errors can occur. Some of the common types of errors include:

1. **Syntax errors:** These are errors that occur when the compiler encounters invalid syntax in the code. Syntax errors can be caused by things like missing semicolons, unmatched parentheses, or incorrect use of keywords.
2. **Type errors:** These are errors that occur when the compiler detects a mismatch between the declared type of a variable or expression and the actual type used in the code. Type errors can be caused by assigning a value of the wrong type to a variable or passing arguments of the wrong type to a function.
3. **Semantic errors:** These are errors that occur when the code is syntactically correct and has no type errors, but still produces unexpected or incorrect results. Semantic errors can be caused by things like incorrect use of logical operators, incorrect order of operations, or incorrect implementation of algorithms.
4. **Linker errors:** These are errors that occur during the linking phase of compilation, where the compiler combines object files and libraries to produce an executable file. Linker errors can be caused by missing libraries or undefined symbols.
5. **Runtime errors:** These are errors that occur during program execution, such as division by zero or accessing an invalid memory location. Runtime errors are not caught by the compiler and can cause the program to crash or produce unexpected results.

Overall, understanding the types of errors that can occur during compilation is essential for effective debugging and troubleshooting of code.

### Reply by Krishnapriya Rajeev

During compilation, several types of errors can occur that prevent the code from being successfully compiled. These errors are called compilation errors or compile-time errors. Here are some of the most common types of compilation errors:

- **Syntax errors:** These errors occur when the code violates the rules of the programming language syntax. For example, missing semicolons, parentheses, or curly braces.
- **Type errors:** These errors occur when the types of variables or arguments do not match the expected type. For example, passing a string to a function that expects an integer.
- **Semantic errors:** These errors occur when the code is syntactically correct but does not behave as intended. For example, using the wrong operator or function to achieve a specific task.
- **Linker errors:** These errors occur when the code references functions or variables that are not defined or cannot be found.
- **Preprocessor errors:** These errors occur when there is a problem with the preprocessor directives. For example, using an undefined macro or a syntax error in a macro definition.
- **Lexical errors:** These errors occur when the program contains spelling or typing mistakes in the code. Lexical errors are also called syntax errors, and they are usually easy to fix. Examples of lexical errors include misspelled variable names, incorrect capitalization, or missing or extra characters.
- **Logical errors:** These errors occur when the program compiles without error, but the output is not what was intended. Logical errors are caused by incorrect algorithms, faulty assumptions, or incorrect calculations.


---

Original Source: https://www.mindstick.com/forum/157729/what-are-the-types-of-errors-that-can-occur-during-compilation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
