diff --git a/src/hotspot/share/sanitizers/ub.hpp b/src/hotspot/share/sanitizers/ub.hpp index 7b0997fdea8..84a31a46ef6 100644 --- a/src/hotspot/share/sanitizers/ub.hpp +++ b/src/hotspot/share/sanitizers/ub.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2024 SAP SE. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,10 @@ // Useful if the function or method is known to do something special or even 'dangerous', for // example causing desired signals/crashes. #ifdef UNDEFINED_BEHAVIOR_SANITIZER -#if defined(__clang__) || defined(__GNUC__) +#if defined(__clang__) +#define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined","float-divide-by-zero"))) +#endif +#if defined(__GNUC__) && !defined(__clang__) #define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined"))) #endif #endif diff --git a/src/java.base/share/native/libjava/ub.h b/src/java.base/share/native/libjava/ub.h index cf7f491ca45..c19403a7f4a 100644 --- a/src/java.base/share/native/libjava/ub.h +++ b/src/java.base/share/native/libjava/ub.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2024 SAP SE. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,10 @@ * following function or method. */ #ifdef UNDEFINED_BEHAVIOR_SANITIZER -#if defined(__clang__) || defined(__GNUC__) +#if defined(__clang__) +#define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined","float-divide-by-zero"))) +#endif +#if defined(__GNUC__) && !defined(__clang__) #define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined"))) #endif #endif