12/10/22, 10:06 AM Semantic Error - javatpoint
Home Compiler Data Structure C C++ C# Java SQL HTML CSS JavaScript
https://www.javatpoint.com/semantic-error 1/6
12/10/22, 10:06 AM Semantic Error - javatpoint
Semantic Error
During the semantic analysis phase, this type of error appears. These types of error are detected at
compile time.
Most of the compile time errors are scope and declaration error. For example: undeclared or
multiple declared identifiers. Type mismatched is another compile time error.
The semantic error can arises using the wrong variable or using wrong operator or doing operation
in wrong order.
Some semantic error can be:
Incompatible types of operands
Undeclared variable
Not matching of actual argument with formal argument
Example 1: Use of a non-initialized variable:
int i;
void f (int m)
{
m=t;
}
In this code, t is undeclared that's why it shows the semantic error.
Example 2: Type incompatibility:
https://www.javatpoint.com/semantic-error 2/6
12/10/22, 10:06 AM Semantic Error - javatpoint
int a = "hello"; // the types String and int are not compatible
Example 3: Errors in expressions:
String s = "...";
int a = 5 - s; // the - operator does not support arguments of type String
← Prev Next →
Youtube For Videos Join Our Youtube Channel: Join Now
Feedback
Send your Feedback to feedback@javatpoint.com
Help Others, Please Share
Learn Latest Tutorials
Splunk tutorial SPSS tutorial
https://www.javatpoint.com/semantic-error 3/6
12/10/22, 10:06 AM Semantic Error - javatpoint
Splunk SPSS
Swagger T-SQL tutorial
tutorial
Transact-SQL
Swagger
Tumblr tutorial React tutorial Regex tutorial Reinforcement
learning tutorial
Tumblr ReactJS Regex
Reinforcement
Learning
R Programming RxJS tutorial React Native Python Design
tutorial tutorial Patterns
RxJS
R Programming React Native Python Design
Patterns
Python Pillow Python Turtle Keras tutorial
tutorial tutorial
Keras
Python Pillow Python Turtle
Preparation
Aptitude Logical Verbal Ability Interview
Reasoning Questions
Aptitude Verbal Ability
Reasoning Interview Questions
Company
Interview
Questions
Company Questions
Trending Technologies
Artificial AWS Tutorial Selenium Cloud
Intelligence tutorial Computing
AWS
Tutorial tutorial
Selenium
https://www.javatpoint.com/semantic-error 4/6
12/10/22, 10:06 AM Semantic Error - javatpoint
Artificial Cloud Computing
Intelligence
Hadoop tutorial ReactJS Data Science Angular 7
Tutorial Tutorial Tutorial
Hadoop
ReactJS Data Science Angular 7
Blockchain Git Tutorial Machine DevOps
Tutorial Learning Tutorial Tutorial
Git
Blockchain Machine Learning DevOps
B.Tech / MCA
DBMS tutorial Data Structures DAA tutorial Operating
tutorial System tutorial
DBMS DAA
Data Structures Operating System
Computer Compiler Computer Discrete
Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
Computer Network Compiler Design
Computer Discrete
Organization Mathematics
Ethical Hacking Computer Software html tutorial
Tutorial Graphics Tutorial Engineering
Web Technology
Tutorial
Ethical Hacking Computer Graphics
Software
Engineering
https://www.javatpoint.com/semantic-error 5/6
12/10/22, 10:06 AM Semantic Error - javatpoint
Cyber Security Automata C Language C++ tutorial
tutorial Tutorial tutorial
C++
Cyber Security Automata C Programming
Java tutorial .Net Python tutorial List of
Framework Programs
Java Python
tutorial
Programs
.Net
Control Data Mining Data
Systems tutorial Tutorial Warehouse
Tutorial
Control System Data Mining
Data Warehouse
https://www.javatpoint.com/semantic-error 6/6