Upgrade to Pro — share decks privately, control downloads, hide ads and more …

教えて!Xcode

 教えて!Xcode

potatotips #59で発表した資料です。
Address sanitizerちょうべんり!

https://potatotips.connpass.com/event/119277/

拙作アプリ「パズル&モナーク」はこちら
https://apple.co/2SkC2Pc
ソースコード
https://github.com/tek-nishi/PuzzleAndMonarch

Nobuyuki Nishiyama

February 28, 2019
Tweet

More Decks by Nobuyuki Nishiyama

Other Decks in Programming

Transcript

  1. QPUBUPUJQT
    ڭ͑ͯʂ9DPEF
    ΅ͬͪήʔϜσϕϩού
    ੢ࢁ৴ߦ

    View full-size slide

  2. wʮͱ͖Ͳ͖࣮੷͕ղআ͞Εͳ͍ʯͱ༑ਓ͔Βใ
    ࠂ͞ΕΔ
    ࣄͷൃ୺

    View full-size slide

  3. w(BNF$FOUFSͷୡ੒߲໨ͬͯৄࡉ͕Ӆṭ͞Εͯ
    Δ͠ɺ௨৴ঢ়گ͕ѱ͔ͬͨͱ͔ͦΜͳΜͰ͠ΐ
    ͏
    w ͳΜͱͳ͘ΩϟογϡΛ࣮૷͓ͯ͘͠
    ౰࣌ͷ෼ੳ

    View full-size slide

  4. ͜ͷ࣌͸͜ΕͰղܾͩͱʜ
    QPUBUPUJQT

    View full-size slide

  5. w"EESFTT4BOJUJ[FS͝ଘ஌Ͱ͔͢ʁ
    w 9DPEF͔Β͋Γ·͢
    9DPEFͷศརͳػೳ

    View full-size slide

  6. wTBOJUJ[F
    w ࿨Β͛Δɺ৺஍Α͘͢Δ
    w Ӵੜతʹ͢Δ
    "EESFTT4BOJUJ[FSʁ

    View full-size slide

  7. wϏϧυ͸௨Δ͕࣮ߦ࣌ͷڍಈ͕ո͍͠΍ͭ
    w͜͏͍ͬͨϛεΛ࣮ߦ࣌ʹݕग़ͯ͠ৄࡉͳϩά
    Λग़ྗͯ͘͠ΕΔ
    ྫ͑͹͜Μͳϛε
    int main()
    {
    int array[10];
    int i = -1; // おっと!!
    array[i] = 0;
    }

    View full-size slide

  8. wϓϩάϥϜ্Ͱͷແ๳ͳϝϞϦΞΫηεΛڭ͑ͯ͘ΕΔ
    w0CKFDUJWF$ͰͷΈ໾ཱͭ
    νΣοΫϘοΫεʹνΣοΫΛೖΕΔ͚ͩʂ

    View full-size slide

  9. w͜͏͍͏ͷ΋ڭ͑ͯ͘ΕΔ
    ϛε͸͠Όʔͳ͍
    #include
    int main()
    {
    int array[9] = {};
    // 配列の内容を出力
    for (int i = 0; i < 10; ++i)
    {
    std::cout << array[i] << "\n";
    }
    }

    View full-size slide

  10. ͬͪ͜͸ͳΜͩΖ͏ʜ

    View full-size slide

  11. w͜ΕͰσόοάͯ͠ΈΔ
    ࢼ͠ʹ0/ʹͯ͠Έͨ

    View full-size slide

  12. ࣮੷Λૹ৴͢ΔஈͰࢭ·ͬͨ
    QPUBUPUJQT

    View full-size slide

  13. ݪҼͱղઆ
    #include
    int* getArray()
    {
    int array[10];
    return array;
    // ローカル変数arrayはここで消滅する
    }
    int main()
    {
    // 配列の場所を受け取る
    int* array = getArray();
    // 配列の内容を出力
    for (int i = 0; i < 10; ++i)
    {
    std::cout << array[i] << "\n";
    }
    }

    View full-size slide

  14. w9DPEFͷ"EESFTT4BOJUJ[FS͸௒པΓʹͳ
    Δʂ
    ·ͱΊ

    View full-size slide

  15. w"EESFTT4BOJUJ[FSͰಠࣗ'SBNFXPSLͷϝϞ
    ϦΤϥʔΛݕग़͢Δ
    w IUUQTRJJUBDPN4$&/&&JUFNT
    EFBDED
    ࢀߟࢿྉ

    View full-size slide

  16. w5XJUUFS!NJOHBNF
    w'BDFCPPLNJOHBNF
    w(JU)VCUFLOJTIJ
    ࣍ͷΞοϓσʔτͰ௚͠·͢ʂ
    ʮύζϧˍϞφʔΫʯ
    ޷ධ഑৴தʂ

    View full-size slide