Compiling principle--Dynamic semantic error and static semantic error

Source: Internet
Author: User



  Dynamic Semantic errors : Logical errors, such as dead loops, are not discovered by the compiler at compile time, but logically this is a mistake;



  Static semantic error : A syntax error that can be found by the compiler, such as (5+6 (); A syntax error that will be found when the compiler compiles;





 
 
#include<iostream>

using namespace std;

int main() {
    
    int k = 0;
    for(; k<=100; );
    {
            k++;
    }
}


As in the code above, there is a for loop followed by a, so this for loop is a dead loop, there is a semantic error, there is no error when compiling, so it is a dynamic semantic error. In C + +, the direct write {} is used to produce a separate scope, which can be compiled through, conforming to lexical, grammatical, and static semantics.






Compiling principle--Dynamic semantic error and static semantic error


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.