Menu

incorrect enum value parsing

2020-06-22
2021-02-12
  • houzhengtao

    houzhengtao - 2020-06-22
    constexpr   int   BASE = 7;
    
    enum enum_test {
        A = BASE + 10,
        B
    };
    
    int test()
    {
        return 100 / B;
    }
    

    error report :
    test_5.cpp:10:16: error: Division by zero. [zerodiv]
            return 100 / B;
                                     ^

    Incorrectly parse enum value B into 0 which is really 18.

     

    Last edit: houzhengtao 2020-06-22
  • CHR

    CHR - 2021-02-12

    This does not reproduce in 2.3.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.