Re: Including config.h emits warnings from -Wundef

2023-08-03 Thread Bruno Haible
Jeffrey Walton wrote:
> My personal opinion is, there's nothing to fix.
> 
> That is exactly how macros are supposed to work. Anything undefined
> evaluates to 0. It has been that way since the early days of C and
> C++.
> 
> If there's a fix, then it is that you don't use -Wundef.

On the simple level "which gcc warning options do I find useful?", I agree
with you.

But one level higher, there are two more questions

1) "Are different GNU packages entitled to using different gcc warning options?"

Yes, of course. Different developers have made different experiences. If Tim
thinks that the '-Wundef' may possibly, some day, help him detect a mistake,
he's perfectly right in using it.

2) "Which warning options from a GNU package does Gnulib need to support,
when compiling a file from that package?"

Here, the answer is: Any except -Werror.

Note that when compiling a .c file from gnulib, we take the freedom to
deactivate warnings as we like; this is the GL_CFLAG_GNULIB_WARNINGS
mechanism.

Bruno






Re: Including config.h emits warnings from -Wundef

2023-08-03 Thread Jeffrey Walton
On Thu, Aug 3, 2023 at 11:52 AM Tim Rühsen  wrote:
>
> I just updated gnulib and recognized these warnings with every '#include
> '. Before the update there were no warnings.
>
> ../config.h:3317:34: warning: "__cplusplus" is not defined, evaluates to
> 0 [-Wundef]
> [...]
> Disabling -Wundef for the whole project is not my preferred solution =).
> Using a #pragma around the #include is ugly and tedious (too many files
> to change).
>
> Can this be fixed in gnulib ?

My personal opinion is, there's nothing to fix.

That is exactly how macros are supposed to work. Anything undefined
evaluates to 0. It has been that way since the early days of C and
C++.

If there's a fix, then it is that you don't use -Wundef.

Jeff



Re: Including config.h emits warnings from -Wundef

2023-08-03 Thread Tim Rühsen

Awesome, thank you Bruno !

Tested and your patch fixes the issue(s) for me.

Tim

On 8/3/23 18:11, Bruno Haible wrote:

On Donnerstag, 3. August 2023 17:52:29 CEST Tim Rühsen wrote:

Hi,

I just updated gnulib and recognized these warnings with every '#include
'. Before the update there were no warnings.

../config.h:3317:34: warning: "__cplusplus" is not defined, evaluates to
0 [-Wundef]
   3317 | #if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 &&
!defined alignof
|  ^~~
../config.h:3318:6: warning: "HAVE_STDALIGN_H" is not defined, evaluates
to 0 [-Wundef]
   3318 | # if HAVE_STDALIGN_H
|  ^~~
../config.h:3415:7: warning: "HAVE_STDALIGN_H" is not defined, evaluates
to 0 [-Wundef]
   3415 | # if !HAVE_STDALIGN_H
|   ^~~
../config.h:3424:6: warning: "_GL_STDALIGN_NEEDS_STDDEF" is not defined,
evaluates to 0 [-Wundef]
   3424 | # if _GL_STDALIGN_NEEDS_STDDEF
|  ^

Disabling -Wundef for the whole project is not my preferred solution =).
Using a #pragma around the #include is ugly and tedious (too many files
to change).


Using a #pragma include config.h would also be ugly.


Can this be fixed in gnulib ?


Done:


2023-08-03  Bruno Haible  

alignasof, stdalign: Avoid some -Wundef warnings from config.h.
Reported by Tim Rühsen  in
.
* m4/stdalign.m4 (gl_ALIGNASOF): Test whether __cplusplus is defined
before evaluating it. Assume HAVE_STDALIGN_H, _GL_STDALIGN_NEEDS_STDDEF
are never defined to 0.

diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index 1a236d66d2..6a39ffe756 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -68,8 +68,10 @@ AC_DEFUN([gl_ALIGNASOF]
dnl The "zz" puts this toward config.h's end, to avoid potential
dnl collisions with other definitions.
AH_VERBATIM([zzalignas],
-[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof
-# if HAVE_STDALIGN_H
+[#if !defined HAVE_C_ALIGNASOF \
+&& !(defined __cplusplus && 201103 <= __cplusplus) \
+&& !defined alignof
+# if defined HAVE_STDALIGN_H
  #  include 
  # endif
  
@@ -166,7 +168,7 @@ AC_DEFUN([gl_ALIGNASOF]

  #   define _Alignas(a) __declspec (align (a))
  #  endif
  # endif
-# if !HAVE_STDALIGN_H
+# if !defined HAVE_STDALIGN_H
  #  if ((defined _Alignas \
  && !(defined __cplusplus \
   && (201103 <= __cplusplus || defined _MSC_VER))) \
@@ -175,7 +177,7 @@ AC_DEFUN([gl_ALIGNASOF]
  #  endif
  # endif
  
-# if _GL_STDALIGN_NEEDS_STDDEF

+# if defined _GL_STDALIGN_NEEDS_STDDEF
  #  include 
  # endif
  #endif])





OpenPGP_signature
Description: OpenPGP digital signature


Re: Including config.h emits warnings from -Wundef

2023-08-03 Thread Bruno Haible
On Donnerstag, 3. August 2023 17:52:29 CEST Tim Rühsen wrote:
> Hi,
> 
> I just updated gnulib and recognized these warnings with every '#include 
> '. Before the update there were no warnings.
> 
> ../config.h:3317:34: warning: "__cplusplus" is not defined, evaluates to 
> 0 [-Wundef]
>   3317 | #if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && 
> !defined alignof
>|  ^~~
> ../config.h:3318:6: warning: "HAVE_STDALIGN_H" is not defined, evaluates 
> to 0 [-Wundef]
>   3318 | # if HAVE_STDALIGN_H
>|  ^~~
> ../config.h:3415:7: warning: "HAVE_STDALIGN_H" is not defined, evaluates 
> to 0 [-Wundef]
>   3415 | # if !HAVE_STDALIGN_H
>|   ^~~
> ../config.h:3424:6: warning: "_GL_STDALIGN_NEEDS_STDDEF" is not defined, 
> evaluates to 0 [-Wundef]
>   3424 | # if _GL_STDALIGN_NEEDS_STDDEF
>|  ^
> 
> Disabling -Wundef for the whole project is not my preferred solution =).
> Using a #pragma around the #include is ugly and tedious (too many files 
> to change).

Using a #pragma include config.h would also be ugly.

> Can this be fixed in gnulib ?

Done:


2023-08-03  Bruno Haible  

alignasof, stdalign: Avoid some -Wundef warnings from config.h.
Reported by Tim Rühsen  in
.
* m4/stdalign.m4 (gl_ALIGNASOF): Test whether __cplusplus is defined
before evaluating it. Assume HAVE_STDALIGN_H, _GL_STDALIGN_NEEDS_STDDEF
are never defined to 0.

diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index 1a236d66d2..6a39ffe756 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -68,8 +68,10 @@ AC_DEFUN([gl_ALIGNASOF]
   dnl The "zz" puts this toward config.h's end, to avoid potential
   dnl collisions with other definitions.
   AH_VERBATIM([zzalignas],
-[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof
-# if HAVE_STDALIGN_H
+[#if !defined HAVE_C_ALIGNASOF \
+&& !(defined __cplusplus && 201103 <= __cplusplus) \
+&& !defined alignof
+# if defined HAVE_STDALIGN_H
 #  include 
 # endif
 
@@ -166,7 +168,7 @@ AC_DEFUN([gl_ALIGNASOF]
 #   define _Alignas(a) __declspec (align (a))
 #  endif
 # endif
-# if !HAVE_STDALIGN_H
+# if !defined HAVE_STDALIGN_H
 #  if ((defined _Alignas \
 && !(defined __cplusplus \
  && (201103 <= __cplusplus || defined _MSC_VER))) \
@@ -175,7 +177,7 @@ AC_DEFUN([gl_ALIGNASOF]
 #  endif
 # endif
 
-# if _GL_STDALIGN_NEEDS_STDDEF
+# if defined _GL_STDALIGN_NEEDS_STDDEF
 #  include 
 # endif
 #endif])






Including config.h emits warnings from -Wundef

2023-08-03 Thread Tim Rühsen

Hi,

I just updated gnulib and recognized these warnings with every '#include 
'. Before the update there were no warnings.


../config.h:3317:34: warning: "__cplusplus" is not defined, evaluates to 
0 [-Wundef]
 3317 | #if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && 
!defined alignof

  |  ^~~
../config.h:3318:6: warning: "HAVE_STDALIGN_H" is not defined, evaluates 
to 0 [-Wundef]

 3318 | # if HAVE_STDALIGN_H
  |  ^~~
../config.h:3415:7: warning: "HAVE_STDALIGN_H" is not defined, evaluates 
to 0 [-Wundef]

 3415 | # if !HAVE_STDALIGN_H
  |   ^~~
../config.h:3424:6: warning: "_GL_STDALIGN_NEEDS_STDDEF" is not defined, 
evaluates to 0 [-Wundef]

 3424 | # if _GL_STDALIGN_NEEDS_STDDEF
  |  ^

Disabling -Wundef for the whole project is not my preferred solution =).
Using a #pragma around the #include is ugly and tedious (too many files 
to change).


Can this be fixed in gnulib ?

Regards, Tim


OpenPGP_signature
Description: OpenPGP digital signature


doc: More platform detail

2023-08-03 Thread Bruno Haible
The configure test shows that Solaris OpenIndiana and Solaris OmniOS don't have
a better fnmatch() implementation than FreeBSD.


2023-08-03  Bruno Haible  

doc: More platform detail.
* doc/posix-functions/fnmatch.texi: Mention Solaris OpenIndiana here,
since it behaves differently than Solaris 11.4.

diff --git a/doc/posix-functions/fnmatch.texi b/doc/posix-functions/fnmatch.texi
index 538d73a9fc..dbd389bba7 100644
--- a/doc/posix-functions/fnmatch.texi
+++ b/doc/posix-functions/fnmatch.texi
@@ -84,7 +84,7 @@
 @c etc.
 @c https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=57911
 FreeBSD 13.2,
-NetBSD 9.3, Cygwin 3.4.6.
+NetBSD 9.3, Solaris 11 OpenIndiana, Cygwin 3.4.6.
 @item
 In the pattern, character classes (such as @code{[:alnum:]}) inside
 bracket expressions fail to match characters outside the single-byte






doc: Add references to FreeBSD bugs

2023-08-03 Thread Bruno Haible
For keeping track of open FreeBSD bugs:


2023-08-03  Bruno Haible  

doc: Add references to FreeBSD bugs.
* doc/posix-functions/fnmatch.texi: Add commented reference to FreeBSD
bug.
* doc/posix-functions/wcscmp.texi: Likewise.
* doc/posix-functions/wcsncmp.texi: Likewise.

diff --git a/doc/posix-functions/fnmatch.texi b/doc/posix-functions/fnmatch.texi
index 1e662a43c1..538d73a9fc 100644
--- a/doc/posix-functions/fnmatch.texi
+++ b/doc/posix-functions/fnmatch.texi
@@ -82,7 +82,9 @@
 @c Failing test cases:
 @c fnmatch ("[[:alnum:]]", "a", 0) == 0
 @c etc.
-FreeBSD 13.2, NetBSD 9.3, Cygwin 3.4.6.
+@c https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=57911
+FreeBSD 13.2,
+NetBSD 9.3, Cygwin 3.4.6.
 @item
 In the pattern, character classes (such as @code{[:alnum:]}) inside
 bracket expressions fail to match characters outside the single-byte
diff --git a/doc/posix-functions/wcscmp.texi b/doc/posix-functions/wcscmp.texi
index 2ce58db350..22d9060d34 100644
--- a/doc/posix-functions/wcscmp.texi
+++ b/doc/posix-functions/wcscmp.texi
@@ -11,7 +11,10 @@
 @item
 This function compares the wide characters as if they were unsigned, although
 @code{wchar_t} is signed, on some platforms:
-glibc 2.14.1 on x86 or x86_64, musl libc 1.2.3, macOS 12.5, FreeBSD 13.2, 
NetBSD 9.0, OpenBSD 7.2, Solaris 11.4.
+glibc 2.14.1 on x86 or x86_64, musl libc 1.2.3, macOS 12.5,
+@c https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272914
+FreeBSD 13.2,
+NetBSD 9.0, OpenBSD 7.2, Solaris 11.4.
 @item
 This function may return a wrong result if the two arguments are of different
 length, on some platforms:
diff --git a/doc/posix-functions/wcsncmp.texi b/doc/posix-functions/wcsncmp.texi
index 46874af46f..4fd90ba95c 100644
--- a/doc/posix-functions/wcsncmp.texi
+++ b/doc/posix-functions/wcsncmp.texi
@@ -11,7 +11,10 @@
 @item
 This function compares the wide characters as if they were unsigned, although
 @code{wchar_t} is signed, on some platforms:
-glibc 2.14.1 on x86 or x86_64, musl libc 1.2.3, macOS 12.5, FreeBSD 13.2, 
NetBSD 9.0, OpenBSD 7.2, Solaris 11.4.
+glibc 2.14.1 on x86 or x86_64, musl libc 1.2.3, macOS 12.5,
+@c https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272915
+FreeBSD 13.2,
+NetBSD 9.0, OpenBSD 7.2, Solaris 11.4.
 @item
 This function may return a wrong result if the two arguments are of different
 length, on some platforms: