[v1,1/2] libcamera: base: regex: Fix preprocessor check
diff mbox series

Message ID 20260428084550.91669-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1,1/2] libcamera: base: regex: Fix preprocessor check
Related show

Commit Message

Barnabás Pőcze April 28, 2026, 8:45 a.m. UTC
clang has no `maybe-uninitialized` warning, therefore the suppression
will generate a compiler error. This was probably hidden by the fact that
`__SANITIZE_*__` macros have only been added to clang since llvm 22.

Link: https://github.com/llvm/llvm-project/commit/568c23bbd3303518c5056d7f03444dae4fdc8a9c
Fixes: b01918978c82 ("libcamera: v4l2_subdevice: Work around false positive warning")
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/base/regex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham April 30, 2026, 10:53 a.m. UTC | #1
Quoting Barnabás Pőcze (2026-04-28 09:45:49)
> clang has no `maybe-uninitialized` warning, therefore the suppression
> will generate a compiler error. This was probably hidden by the fact that
> `__SANITIZE_*__` macros have only been added to clang since llvm 22.
> 
> Link: https://github.com/llvm/llvm-project/commit/568c23bbd3303518c5056d7f03444dae4fdc8a9c
> Fixes: b01918978c82 ("libcamera: v4l2_subdevice: Work around false positive warning")
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  include/libcamera/base/regex.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/libcamera/base/regex.h b/include/libcamera/base/regex.h
> index 45f4da8cb..c80cca6fe 100644
> --- a/include/libcamera/base/regex.h
> +++ b/include/libcamera/base/regex.h
> @@ -8,7 +8,7 @@
>  #include <libcamera/base/private.h>
>  
>  #pragma GCC diagnostic push
> -#if defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__
> +#if (defined(__GNUC__) && !defined(__clang__)) && defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__
>  #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>  #endif
>  #include <regex>
> -- 
> 2.54.0
>
Laurent Pinchart June 11, 2026, 3:53 p.m. UTC | #2
Hi Barnabás,

Thank you for the patch.

On Tue, Apr 28, 2026 at 10:45:49AM +0200, Barnabás Pőcze wrote:
> clang has no `maybe-uninitialized` warning, therefore the suppression
> will generate a compiler error. This was probably hidden by the fact that
> `__SANITIZE_*__` macros have only been added to clang since llvm 22.
> 
> Link: https://github.com/llvm/llvm-project/commit/568c23bbd3303518c5056d7f03444dae4fdc8a9c
> Fixes: b01918978c82 ("libcamera: v4l2_subdevice: Work around false positive warning")
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  include/libcamera/base/regex.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/libcamera/base/regex.h b/include/libcamera/base/regex.h
> index 45f4da8cb..c80cca6fe 100644
> --- a/include/libcamera/base/regex.h
> +++ b/include/libcamera/base/regex.h
> @@ -8,7 +8,7 @@
>  #include <libcamera/base/private.h>
>  
>  #pragma GCC diagnostic push
> -#if defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__
> +#if (defined(__GNUC__) && !defined(__clang__)) && defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__

It's annoying how clang (and other compilers too) try to pass as gcc :-/

>  #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

And interpreting #pragma GCC *and* throwing errors at warnings they
don't understand is just outrageous.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  #endif
>  #include <regex>

Patch
diff mbox series

diff --git a/include/libcamera/base/regex.h b/include/libcamera/base/regex.h
index 45f4da8cb..c80cca6fe 100644
--- a/include/libcamera/base/regex.h
+++ b/include/libcamera/base/regex.h
@@ -8,7 +8,7 @@ 
 #include <libcamera/base/private.h>
 
 #pragma GCC diagnostic push
-#if defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__
+#if (defined(__GNUC__) && !defined(__clang__)) && defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__
 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #endif
 #include <regex>