bugGNU Screen - Bugs: bug #66416, tests broken on c23

 
 

bug #66416: tests broken on c23

Submitter:  Jeffrey Cliff <themusicgod1>
Submitted:  Wed 06 Nov 2024 06:56:51 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  * 5 - Normal Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Release:  5.0.0
Fixed Release:  None Planned Release:  None
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 07 Nov 2024 09:03:54 AM UTC, comment #2: 

propos initial :

> gcc 15 seems to be more strict about casting, [...]


Casts are fine. GCC 15 is just stricter about implicit conversions (casts are explicit conversions).

> casts from pointers without a cast are more strict in c23


should have been "conversions from pointers without a cast [...]".

commentaire #1 :

> [ note: drat, missed the title.  this turns out to not actually be a c23 issue as i thought, but a gcc15 issue ]


Indeed. This comes from
  https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=9715c545d33b3a32ddc1ae817ba9356ade1fb9df
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96284 (partly)

It seems that the code is allowed by any version of the ISO C standard (e.g., in C23 6.3.2.3p7: "A pointer to an object type may be converted to a pointer to a different object type." with just an obvious restriction about the alignment). A diagnostic isn't even required.

Vincent Lefèvre <vinc17>
Wed 06 Nov 2024 06:57:50 PM UTC, comment #1: 

[ note: drat, missed the title.  this turns out to not actually be a c23 issue as i thought, but a gcc15 issue ]

Jeffrey Cliff <themusicgod1>
Wed 06 Nov 2024 06:56:51 PM UTC, original submission:  

gcc gcc (GCC) 15.0.0 20240509 (experimental)
with CFLAGS=""
screen 5.0

./configure arguments:
--prefix=/usr                                    --infodir=/usr/share/info                        --mandir=/usr/share/man                          --disable-pam                                    --enable-socket-dir=/run/screen                  --with-pty-group=5                               --with-system_screenrc=/etc/screenrc

gcc 15 seems to be more strict about casting, the attached patch makes the tests at least compile to the point where the assertions fail

types of failures

1)

SIGNATURE_CHECK is checking an incorrect signature

tests/test-winmsgcond.c:29:17: error: initialization of ‘void ()(WinMsgCond , char )’ from incompatible pointer type ‘void ()(WinMsgCond *, int)’ [-Wincompatible-pointer-types]
   29 | SIGNATURE_CHECK(wmc_init, void, (WinMsgCond , char ));
      |                 ^~~~~~~~
tests/signature.h:46:71: note: in definition of macro ‘SIGNATURE_CHECK2’
   46 |   static ret (* _attribute_((unused)) signature_check ## id) args = fn
      |                                                                       ^~
tests/signature.h:39:3: note: in expansion of macro ‘SIGNATURE_CHECK1’
   39 |   SIGNATURE_CHECK1 (fn, ret, args, _LINE_)
      |   ^~~~~~~~~~~~~~~~
tests/test-winmsgcond.c:29:1: note: in expansion of macro ‘SIGNATURE_CHECK’
   29 | SIGNATURE_CHECK(wmc_init, void, (WinMsgCond , char ));
      | ^~~~~~~~~~~~~~~
tests/test-winmsgcond.c:34:17: error: initialization of ‘char ()(WinMsgCond , char , _Bool )’ from incompatible pointer type ‘int ()(WinMsgCond , int,  _Bool )’ [-Wincompatible-pointer-types]
   34 | SIGNATURE_CHECK(wmc_else, char , (WinMsgCond , char , bool ));
      |                 ^~~~~~~~
tests/signature.h:46:71: note: in definition of macro ‘SIGNATURE_CHECK2’
   46 |   static ret (* _attribute_((unused)) signature_check ## id) args = fn
      |                                                                       ^~
tests/signature.h:39:3: note: in expansion of macro ‘SIGNATURE_CHECK1’
   39 |   SIGNATURE_CHECK1 (fn, ret, args, _LINE_)
      |   ^~~~~~~~~~~~~~~~
tests/test-winmsgcond.c:34:1: note: in expansion of macro ‘SIGNATURE_CHECK’
   34 | SIGNATURE_CHECK(wmc_else, char , (WinMsgCond , char , bool ));
      | ^~~~~~~~~~~~~~~


2)

casts from pointers without a cast are more strict in c23


tests/test-winmsgcond.c: In function ‘main’:
tests/test-winmsgcond.c:46:32: error: passing argument 2 of ‘wmc_init’ makes integer from pointer without a cast [-Wint-conversion]
   46 |                 wmc_init(&wmc, pos);
      |                                ^~~
      |                                |
      |                                char *

In file included from tests/test-winmsgcond.c:27:
tests/test-winmsgcond.c:53:42: error: passing argument 2 of ‘wmc_end’ makes integer from pointer without a cast [-Wint-conversion]
   53 |                 ASSERT(wmc_end(&wmc, pos + 1, &chg) == pos);
      |                                      ~~~~^~~
      |                                          |
      |                                          char *


the attached patch explicitly casts enough to get these errors to no longer be errors.

3)
for some reason when "make check" is run _GNU_SOURCE is not defined

 this leads to mallocmock_reset not being defined at linking stage

/sources/gnu/screen-5.0.0/tests/test-winmsgbuf.c:62:(.text.startup+0x5a): undefined reference to `mallocmock_reset'
/usr/bin/ld: /sources/gnu/screen-5.0.0/tests/test-winmsgbuf.c:66:(.text.startup+0x8d): undefined reference to `mallocmock_reset'
/usr/bin/ld: /sources/gnu/screen-5.0.0/tests/test-winmsgbuf.c:67:(.text.startup+0xc7): undefined reference to `mallocmock_reset'
/usr/bin/ld: /sources/gnu/screen-5.0.0/tests/test-winmsgbuf.c:68:(.text.startup+0x100): undefined reference to `mallocmock_reset'
collect2: error: ld returned 1 exit status

configure does adds it to config.h correctly

# grep -i '_GNU_SOURCE' config.h
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1

but when make check occurs

gcc -iquote. -DSCREENENCODINGS='"/usr/share/screen/utf8encodings"' -DBUILD_DATE='"2024-11-06 12:11:24"' -g -O2 -Wall -Wextra -std=c17 tests/test-winmsgbuf.c -o tests/test-winmsgbuf winmsgbuf.o tests/mallocmock.o
 
it fails.

one solution is just to remove the definition of mallocmock_reset from the ifdef defining _GNU_SOURCE but this is probably not the correct way to solve that.

Jeffrey Cliff <themusicgod1>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #56603:  screen-test2.patch added by themusicgod1 (6KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by vinc17 (Posted a comment)
  • -email is unavailable- added by themusicgod1 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-11-06 themusicgod1 Attached File- Added screen-test2.patch, #56603

    Back to the top

    Powered by Savane 3.14-7003.
    Corresponding source code