11 Replies
      Latest reply on Jul 20, 2019 12:01 PM by somethingelse
      yetanothermeagain Level 1 Level 1 (0 points)

        Xcode (tested with 10, and Xcode 11 Betas) allows a pointer to NSDictionary* (a pointer to a pointer) be used instead of a pointer to NSMutableDictionary*, which leads to a runtime crash instead of expected compilation error. I submitted a bug about it, but the bug returned with "works with clang-1001.0.46.3 which is part of Xcode 10.2". i wonder what that means to me as I do not use clang in terminal, only via Xcode. Can / should I somehow change the clang version that is used by Xcode?

         

        a side question, are there several versions of clang installed with Xcode and for whatever reason Xcode is not using the latest one?

         

        void foo(NSMutableDictionary** mutableDictionary) {

            (*mutableDictionary)[@"hello"] = @"world";

        }

         

        ...

            NSDictionary* dictionary = [NSDictionary new];

            foo(&dictionary); // no compilation error here!

         

            // runtime error:

            // *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionary0 setObject:forKeyedSubscript:]: unrecognized selector sent to instance

        ....

         

        originally rdar://49775697

        plus FB6447069, this time against Xcode