-

   rss_forum_sources_ru

 - e-mail

 

 -

 LiveInternet.ru:
: 29.07.2007
:
:
: 80

:


UB

, 25 2021 . 21:44 +
applegame: :
    static int foo(int m, int n) {
    if (m == 0) return n + 1;
    if (n == 0) return foo(m - 1, 1);
    return foo(m - 1, n - 1);
    }
    int main() {
    int n = 1;
    *const_cast(&n) = foo(10, 12);
    return n;
    }

-O3
    main:
    mov eax, 3
    ret

UB:
    static int foo(int m, int n) {
    if (m == 0) return n + 1;
    if (n == 0) return foo(m - 1, 1);
    return foo(m - 1, n - 1);
    }
    int main() {
    const int n = 1;
    *const_cast(&n) = foo(10, 12);
    return n;
    }

, , ( , ), :
    main:
    mov eax, 1
    ret

, . UB - . ? 99.9999% , . , ?


Qraizer @
, , , . ?
- , UB- . , . . , .
UB, .
UB , . ?

https://forum.sources.ru/index.php?showtopic=421537&view=findpost&p=3848399

:  

: [1] []
 

:
: 

: ( )

:

  URL