[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 --- Comment #9 from Andrew Pinski --- (In reply to Fangrui Song from comment #8) > Note: Clang supports > __attribute__((no_sanitize("address","undefined"))) > but not > __attribute__((no_sanitize("address,undefined"))) > > Possibly reject `__attribute__((no_sanitize("address,undefined")))` as well > to prevent users from writing non-portable code. We document both ways already. https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html#index-no_005fsanitize-function-attribute I would have said if we don't document both ways we should reject it but since it is documented already, maybe add to the documentation that clang does not accept the combined string way.
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 Fangrui Song changed: What|Removed |Added CC||i at maskray dot me --- Comment #8 from Fangrui Song --- Note: Clang supports __attribute__((no_sanitize("address","undefined"))) but not __attribute__((no_sanitize("address,undefined"))) Possibly reject `__attribute__((no_sanitize("address,undefined")))` as well to prevent users from writing non-portable code.
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 Martin Liška changed: What|Removed |Added Status|NEW |RESOLVED Known to work||8.0 Resolution|--- |FIXED --- Comment #7 from Martin Liška --- Implemented in GCC 8.0.
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 --- Comment #6 from Martin Liška --- Author: marxin Date: Tue Jun 13 13:59:05 2017 New Revision: 249158 URL: https://gcc.gnu.org/viewcvs?rev=249158&root=gcc&view=rev Log: Implement no_sanitize function attribute 2017-06-13 Martin Liska PR sanitize/78204 * c-c++-common/ubsan/attrib-2.c (float_cast2): Enhance the test by adding no_sanitize attribute. * gcc.dg/asan/use-after-scope-4.c: Likewise. 2017-06-13 Martin Liska PR sanitize/78204 * c-attribs.c (add_no_sanitize_value): New function. (handle_no_sanitize_attribute): Likewise. (handle_no_sanitize_address_attribute): Use the function. (handle_no_sanitize_thread_attribute): New function. (handle_no_address_safety_analysis_attribute): Use add_no_sanitize_value. (handle_no_sanitize_undefined_attribute): Likewise. * c-common.h: Declare new functions. * c-ubsan.c (ubsan_instrument_division): Use sanitize_flags_p. (ubsan_instrument_shift): Likewise. (ubsan_instrument_bounds): Likewise. (ubsan_maybe_instrument_array_ref): Likewise. (ubsan_maybe_instrument_reference_or_call): Likewise. 2017-06-13 Martin Liska PR sanitize/78204 * asan.c (asan_sanitize_stack_p): Use sanitize_flags_p. (gate_asan): Likewise. * asan.h (asan_no_sanitize_address_p): Remove the function. (sanitize_flags_p): New function. * builtins.def: Fix coding style. * common.opt: Use renamed enum value. * convert.c (convert_to_integer_1): Use sanitize_flags_p. * doc/extend.texi: Document no_sanitize attribute. * flag-types.h (enum sanitize_code): Rename SANITIZE_NONDEFAULT to SANITIZE_UNDEFINED_NONDEFAULT. * gcc.c (sanitize_spec_function): Use the renamed enum value. * gimple-fold.c (optimize_atomic_compare_exchange_p): Use sanitize_flags_p. * gimplify.c (gimplify_function_tree): Likewise. * ipa-inline.c (sanitize_attrs_match_for_inline_p): Likewise. * opts.c (parse_no_sanitize_attribute): New function. (common_handle_option): Use renamed enum value. * opts.h (parse_no_sanitize_attribute): Declare. * tree.c (sanitize_flags_p): New function. * tree.h: Declared here. * tsan.c: Use sanitize_flags_p. * ubsan.c (ubsan_expand_null_ifn): Likewise. (instrument_mem_ref): Likewise. (instrument_bool_enum_load): Likewise. (do_ubsan_in_current_function): Remove the function. (pass_ubsan::execute): Use sanitize_flags_p. * ubsan.h: Remove do_ubsan_in_current_function * tree-cfg.c (print_no_sanitize_attr_value): New function. (dump_function_to_file): Use it here. 2017-06-13 Martin Liska PR sanitize/78204 * class.c (build_base_path): Use sanitize_flags_p. * cp-gimplify.c (cp_genericize_r): Likewise. (cp_genericize_tree): Likewise. (cp_genericize): Likewise. * cp-ubsan.c (cp_ubsan_instrument_vptr_p): Likewise. * decl.c (compute_array_index_type): Likewise. (start_preparsed_function): Likewise. * decl2.c (one_static_initialization_or_destruction): Likewise. * init.c (finish_length_check): Likewise. * lambda.c (maybe_add_lambda_conv_op): Likewise. * typeck.c (cp_build_binary_op): Likewise. (build_static_cast_1): Likewise. 2017-06-13 Martin Liska PR sanitize/78204 * c-convert.c (convert): Use sanitize_flags_p. * c-decl.c (grokdeclarator): Likewise. * c-typeck.c (convert_for_assignment): Likewise. (c_finish_return): Likewise. (build_binary_op): Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/asan.c trunk/gcc/asan.h trunk/gcc/builtins.def trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-attribs.c trunk/gcc/c-family/c-common.h trunk/gcc/c-family/c-ubsan.c trunk/gcc/c-family/c-ubsan.h trunk/gcc/c/ChangeLog trunk/gcc/c/c-convert.c trunk/gcc/c/c-decl.c trunk/gcc/c/c-typeck.c trunk/gcc/common.opt trunk/gcc/convert.c trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/cp/cp-gimplify.c trunk/gcc/cp/cp-ubsan.c trunk/gcc/cp/decl.c trunk/gcc/cp/decl2.c trunk/gcc/cp/init.c trunk/gcc/cp/lambda.c trunk/gcc/cp/typeck.c trunk/gcc/doc/extend.texi trunk/gcc/flag-types.h trunk/gcc/gcc.c trunk/gcc/gimple-fold.c trunk/gcc/gimplify.c trunk/gcc/ipa-inline.c trunk/gcc/opts.c trunk/gcc/opts.h trunk/gcc/sanopt.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/c-c++-common/ubsan/attrib-2.c trunk/gcc/testsuite/gcc.dg/asan/use-after-scope-4.c trunk/gcc/tree-cfg.c trunk/gcc/tsan.c trunk/gcc/ubsan.c trunk/gcc/ubsan.h
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 Martin Liška changed: What|Removed |Added Target Milestone|--- |8.0 --- Comment #5 from Martin Liška --- > > It looks like GCC does not support this feature in any compilers (GCC 4 > through 7). Is that correct? > > (I'm trying to get some macros tuned based on Clang and GCC versions). No, it doesn't. But I've got a patch that can be merged for GCC 8.
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 --- Comment #4 from Jeffrey Walton --- (In reply to Martin Liška from comment #3) > As I'm reading the source code, there's no option to do that. > Apart from 'no_sanitize' attribute, GCC supports 'no_sanitize_undefined' > attribute (clang does not) and clang has 'no_sanitize_memory' (not handled > by GCC). > > I welcome the ability to have finer attributes for sanitizer and I can do > that. > What's Jakub thinking about it? (In reply to Martin Liška from comment #1) > Ok, do I understand it properly that you're missing support of > no_sanitize("string literals"), as defined here: > > http://clang.llvm.org/docs/AttributeReference.html#no-sanitize-clang-no- > sanitize It looks like GCC does not support this feature in any compilers (GCC 4 through 7). Is that correct? (I'm trying to get some macros tuned based on Clang and GCC versions).
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 Martin Liška changed: What|Removed |Added Status|WAITING |NEW Severity|normal |enhancement --- Comment #3 from Martin Liška --- As I'm reading the source code, there's no option to do that. Apart from 'no_sanitize' attribute, GCC supports 'no_sanitize_undefined' attribute (clang does not) and clang has 'no_sanitize_memory' (not handled by GCC). I welcome the ability to have finer attributes for sanitizer and I can do that. What's Jakub thinking about it?
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 --- Comment #2 from Jan Kratochvil --- Yes, that would be the best, to stay compatible with clang. Or is there some other way how to disable -fsanitize=float-divide-by-zero only for one function / block of code?
[Bug sanitizer/78204] ‘no_sanitize’ attribute directive ignored [-Wattributes]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204 Martin Liška changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2016-11-04 CC||marxin at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Martin Liška --- Ok, do I understand it properly that you're missing support of no_sanitize("string literals"), as defined here: http://clang.llvm.org/docs/AttributeReference.html#no-sanitize-clang-no-sanitize