public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jongampark at sbcglobal dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug objc/36283] When a class method, pointed by id, returns float, it returns wrong value Date: Wed, 21 May 2008 04:41:00 -0000 [thread overview] Message-ID: <20080521044030.366.qmail@sourceware.org> (raw) In-Reply-To: <bug-36283-16200@http.gcc.gnu.org/bugzilla/> [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1848 bytes --] ------- Comment #5 from jongampark at sbcglobal dot net 2008-05-21 04:40 ------- I tried it on my MacBook with 4.0.1 version of gcc. ( provided by Apple Inc. ) - (void)add:(id)valObj { float temp_value; // If I cast this way temp_value = (float)[valObj value]; // I changed "data" to "value", to see if I had misfortune in choosing message name. // it displays a message, "error:pointer value used where a floating point value was expected. It seems to me that it means the return value by sending message "value" is recognized as a pointer. // If I cast this way temp_value = [(GFloat *)valObj value]; It compiles without any problem and returns correct value. So, does it mean that we can't rely on the returned value when using id? By the way, the Objective-C programming language manual from Apple describes : Return and Argument Types In general, methods in different classes that have the same selector (the same name) must also share the same return and argument types. This constraint is imposed by the compiler to allow dynamic binding. Because the class of a message receiver (and therefore class-specific details about the method its asked to perform), cant be known at compile time, the compiler must treat all methods with the same name alike. When it prepares information on method return and argument types for the runtime system, it creates just one method description for each method selector. Then... wouldn't it be better to present error message in the case of my test code? Because the return type of the same message of GInt, and GFloat are different, i.e. int and float, respectively, it violates the explanation above. Instead of allowing the compilation, it would be good to prevent compilation or somewhat better error message. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36283
next prev parent reply other threads:[~2008-05-21 4:41 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-05-20 20:45 [Bug objc/36283] New: " jongampark at sbcglobal dot net 2008-05-20 21:03 ` [Bug objc/36283] " pinskia at gcc dot gnu dot org 2008-05-20 21:06 ` pinskia at gcc dot gnu dot org 2008-05-21 2:57 ` jongampark at sbcglobal dot net 2008-05-21 3:01 ` jongampark at sbcglobal dot net 2008-05-21 4:41 ` jongampark at sbcglobal dot net [this message] 2008-05-21 14:57 ` jongampark at sbcglobal dot net 2008-12-28 21:39 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080521044030.366.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).