Bug #6066
closedFix "control may reach end of non-void function" warnings for clang
Added by drbrain (Eric Hodel) over 13 years ago. Updated over 13 years ago.
Description
=begin
clang 3.1 is more picky about "control may reach end of non-void function"
The attached patches contain add (({return Qnil; /* not reached */})) or the equivalent where the warnings occurred.
=end
Files
fiddle.return.patch (404 Bytes) fiddle.return.patch | ext/fiddle patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
ripper.return.patch (391 Bytes) ripper.return.patch | ext/ripper patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
socket.return.patch (774 Bytes) socket.return.patch | ext/socket patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
tk.return.patch (1.46 KB) tk.return.patch | ext/tk patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
return.combined.patch (10.4 KB) return.combined.patch | Combined patch for core and ext/ | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
core.return.patch (5.75 KB) core.return.patch | Patch for C files in the project root | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
bigdecimal.return.patch (409 Bytes) bigdecimal.return.patch | ext/bigdecimal patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
digest.return.patch (904 Bytes) digest.return.patch | ext/digest patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
dl.return.patch (354 Bytes) dl.return.patch | ext/dl patch | drbrain (Eric Hodel), 02/23/2012 09:39 AM | |
return.UNREACHABLE.patch (10.9 KB) return.UNREACHABLE.patch | Updated combined patch using UNREACHABLE | drbrain (Eric Hodel), 02/26/2012 01:39 PM | |
return.not_reached.convert.patch (10.7 KB) return.not_reached.convert.patch | update /* not reached */ to UNREACHABLE | drbrain (Eric Hodel), 02/26/2012 02:08 PM |
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#1
[ruby-core:42816]
Patches were not added in-order.
Note that return.combined.patch contains all the other patches grouped together
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Actions
#2
[ruby-core:42830]
clang 3.1 is more picky about "control may reach end of non-void function"
or doesn't deal with noreturn attribute properly?
Anyway, (ID)NULL seems odd.
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#3
[ruby-core:42849]
=begin
Yes, (ID)NULL seems odd to me too.
clang supports __builtin_unreachable():
http://clang.llvm.org/docs/LanguageExtensions.html#__builtin_unreachable
It looks like replacing (({return Qnil; /* NOT REACHED */})) lines with __builtin_unreachable() may improve optimizations with clang.
Adding configure support to detect __builltin_unreachable() looks like it is beyond my knowledge based on the __builtin_setjmp() detection, can you help me?
=end
Updated by naruse (Yui NARUSE) over 13 years ago
Actions
#4
[ruby-core:42910]
- Status changed from Open to Closed
r34784 uses __builtin_unreachable().
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Actions
#5
[ruby-core:42912]
- Status changed from Closed to Open
No, the commit just checks the function, and defines UNREACHABLE macro.
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#6
[ruby-core:42937]
Thank you, I will post an updated patch using UNREACHABLE
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#7
[ruby-core:42944]
- File return.UNREACHABLE.patch return.UNREACHABLE.patch added
This patch updates all -Wreturn-type warning locations to use the UNREACHABLE macro.
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#8
[ruby-core:42946]
=begin
This patch updates existing (({return Qnil; /* not reached */})) with (({UNREACHABLE;}))
I did not change (({trace_en()})) in variable.c as it seems to return, I think the (({/* not reached */})) should be removed, but can you check it?
=end
Updated by ko1 (Koichi Sasada) over 13 years ago
Actions
#9
- Assignee set to nobu (Nobuyoshi Nakada)
Updated by shyouhei (Shyouhei Urabe) over 13 years ago
Actions
#10
- Status changed from Open to Assigned
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#11
[ruby-core:44293]
Nobu, may I commit this?
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Actions
#12
[ruby-core:44298]
- Assignee changed from nobu (Nobuyoshi Nakada) to drbrain (Eric Hodel)
Feel free.
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#13
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r35321.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "control
reaches end of non-void function" warnings. [ruby-trunk - Bug #6066] - re.c (name_to_backref_number): ditto.
- object.c (rb_Float): ditto.
- io.c (io_readpartial): ditto.
- io.c (io_read_nonblock): ditto.
- pack.c (rb_uv_to_utf8): ditto.
- proc.c (rb_method_entry_arity): ditto.
- vm_method.c (rb_f_notimplement): ditto.
- struct.c (rb_struct_aset_id): ditto.
- class.c (rb_scan_args): ditto.
- process.c (rlimit_resource_type): ditto.
- process.c (rlimit_resource_value): ditto.
- process.c (p_uid_switch): ditto.
- process.c (p_gid_switch): ditto.
- ext/digest/digest.c (rb_digest_instance_update): ditto.
- ext/digest/digest.c (rb_digest_instance_finish): ditto.
- ext/digest/digest.c (rb_digest_instance_reset): ditto.
- ext/digest/digest.c (rb_digest_instance_block_length): ditto.
- ext/bigdecimal/bigdecimal.c (BigDecimalCmp): ditto.
- ext/dl/handle.c (rb_dlhandle_close): ditto.
- ext/tk/tcltklib.c (pending_exception_check0): ditto.
- ext/tk/tcltklib.c (pending_exception_check1): ditto.
- ext/tk/tcltklib.c (ip_cancel_eval_core): ditto.
- ext/tk/tcltklib.c (lib_get_reltype_name): ditto.
- ext/tk/tcltklib.c (create_dummy_encoding_for_tk_core): ditto.
- ext/tk/tkutil/tkutil.c (tk_hash_kv): ditto.
- ext/openssl/ossl_ssl.c (ossl_ssl_session_reused): ditto.
- ext/openssl/ossl_pkey_ec.c (ossl_ec_key_dsa_verify_asn1): ditto.
- ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_at_infinit): ditto.
- ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_on_curve): ditto.
- ext/fiddle/conversions.c (generic_to_value): ditto.
- ext/socket/raddrinfo.c (rsock_io_socket_addrinfo): ditto.
- ext/socket/socket.c (sock_s_getnameinfo): ditto.
- ext/ripper/eventids2.c (ripper_token2eventid): ditto.
- cont.c (return_fiber): ditto.
- dmydln.c (dln_load): ditto.
- vm_insnhelper.c (vm_search_normal_superclass): ditto.
- bignum.c (big_fdiv): ditto.
- marshal.c (r_symlink): ditto.
- marshal.c (r_symbol): ditto.
Updated by drbrain (Eric Hodel) over 13 years ago
Actions
#14
[ruby-core:44352]
r35322 is also part of this bug, but I forgot to mention it in my commit message.
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Actions
#15
[ruby-core:44362]
- Category set to misc
- Status changed from Closed to Assigned
- Target version set to 2.0.0
Thank you for the commit, and found r35322 let older compilers and non-gcc compilers warn unreachable code.
UNREACHABLE should not replace those `return's, but be appended, I think.
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Actions
#16
[ruby-core:44363]
- % Done changed from 100 to 50
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Actions
#17
[ruby-core:44407]
- Status changed from Assigned to Closed
- % Done changed from 50 to 100