Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.7d: is not gcc 14.x ready #283

Closed
kloczek opened this issue Jan 24, 2024 · 3 comments
Closed

2.2.7d: is not gcc 14.x ready #283

kloczek opened this issue Jan 24, 2024 · 3 comments
Labels
Oops OS/Libc/Compiler problem

Comments

@kloczek
Copy link

kloczek commented Jan 24, 2024

Looks like last version build fails with latest gcc 14.x which is now used in fedora rawhide.

Build fails with
[tkloczko@pers-jacek discount-2.2.7d]$ make -k
/usr/bin/gcc -Wno-return-type -Wno-implicit-int -I. -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -fPIC -c main.c
main.c: warning: -Wno-implicit-int detected - is this intentional ?
main.c: In function ‘main’:
main.c:311:36: error: passing argument 2 of ‘mkd_e_code_format’ from incompatible pointer type [-Wincompatible-pointer-types]
  311 |             mkd_e_code_format(doc, external_codefmt);
      |                                    ^~~~~~~~~~~~~~~~
      |                                    |
      |                                    char * (*)(char *, int,  char *)
In file included from main.c:12:
./mkdio.h:71:31: note: expected ‘mkd_callback_t’ {aka ‘char * (*)(const char *, const int,  void *)’} but argument is of type ‘char * (*)(char *, int,  char *)’
   71 | void mkd_e_code_format(void*, mkd_callback_t);
      |                               ^~~~~~~~~~~~~~
make: *** [Makefile:127: main.o] Error 1
@Orc
Copy link
Owner

Orc commented Jan 24, 2024

  1. Does this happen with discount v3?
  2. Does this happen with CC="cc -std=c89"

gcc 14 apparently isn't discount ready, so if you could check these out for me (or send me a patch) that would be wonderful.

@Orc Orc added the Oops OS/Libc/Compiler problem label Feb 7, 2024
@Orc
Copy link
Owner

Orc commented Feb 7, 2024

For the 2.2 series, compile it with `CC="cc -std=c89". I got fed up with the warnings in v3, so there you can do the gcc of your choice.

@Orc Orc closed this as completed Feb 7, 2024
@badshah400
Copy link

I know this issue is closed, but I worked on this while fixing RPM package builds for openSUSE before I saw this issue, and decided to attach this patch for what it is worth. I have checked that, with the following patch applied, discount 2.2.7d builds with GCC 14 and the tests succeed.

---
 main.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Index: discount-2.2.7d/main.c
===================================================================
--- discount-2.2.7d.orig/main.c
+++ discount-2.2.7d/main.c
@@ -100,14 +100,15 @@ free_it(char *object, void *ctx)
 }
 
 char *
-external_codefmt(char *src, int len, char *lang)
+external_codefmt(const char *src, const int len, void *lang)
 {
     int extra = 0;
     int i, x;
     char *res;
+    char *ec_lang = (char *)lang;
 
-    if ( lang == 0 )
-	lang = "generic_code";
+    if ( ec_lang == 0 )
+	ec_lang = "generic_code";
 
     for ( i=0; i < len; i++) {
 	if ( src[i] == '&' )
@@ -117,11 +118,11 @@ external_codefmt(char *src, int len, cha
     }
 
     /* 80 characters for the format wrappers */
-    if ( (res = malloc(len+extra+80+strlen(lang))) ==0 )
+    if ( (res = malloc(len+extra+80+strlen(ec_lang))) ==0 )
 	/* out of memory?  drat! */
 	return 0;
 
-    sprintf(res, "<pre><code class=\"%s\">\n", lang);
+    sprintf(res, "<pre><code class=\"%s\">\n", ec_lang);
     x = strlen(res);
     for ( i=0; i < len; i++ ) {
 	switch (src[i]) {

soult pushed a commit to soult/text-markdown-discount that referenced this issue Oct 5, 2024
The discount library fails to compile with GCC 14. The author of the library
has already fixed the issue for discount v3.0.0+[1], but upgrading would
require adjusting to some significant API changes.

This commit applies a patch provided by Atri Bhattacharya for OpenSUSE[1] and
also used by Gentoo.[2]

1: Orc/discount#283
2: https://bugs.gentoo.org/894560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Oops OS/Libc/Compiler problem
Projects
None yet
Development

No branches or pull requests

3 participants