Thread overview
[Issue 24297] ImportC incompatible with glibc _FORTIFY_SOURCE
Dec 24, 2023
Walter Bright
Dec 24, 2023
Vladimir Panteleev
Dec 24, 2023
Vladimir Panteleev
Dec 24, 2023
Vladimir Panteleev
Dec 27, 2023
Dlang Bot
Dec 27, 2023
Dlang Bot
December 24, 2023
https://issues.dlang.org/show_bug.cgi?id=24297

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
The usual way to handle these sorts of extensions is to make macros for them that expand to nothing, and put those macros in druntime/src/importc.h.

However, this bug report has insufficient information in it to do that, though I suspect that an:

    #undef _FORTIFY_SOURCE

might work?

--
December 24, 2023
https://issues.dlang.org/show_bug.cgi?id=24297

--- Comment #2 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
> However, this bug report has insufficient information in it to do that

Why do you say that? This problem should be reproducible on any GNU/Linux machine without additional setup.

What information is missing?

> though I suspect that an:
> 
>     #undef _FORTIFY_SOURCE
> 
> might work?

Ah, certainly, that works! Not worth fixing whatever things get expanded to?

--
December 24, 2023
https://issues.dlang.org/show_bug.cgi?id=24297

--- Comment #3 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Here is the preprocessed code:

# 194 "/usr/include/bits/stdio2.h" 3 4
extern
# 194 "/usr/include/bits/stdio2.h"
inline
# 194 "/usr/include/bits/stdio2.h" 3 4
__attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__))
__attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__))
__attribute__ ((__access__ (__write_only__, 1, 2))) char *
fgets (char * __s, int __n, FILE * __stream)
{
  size_t sz = __builtin_object_size (__s, 1 > 1);
  if (((__builtin_constant_p (sz) && (sz) == (long unsigned int) -1) ||
(((__typeof (__n)) 0 < (__typeof (__n)) -1 || (__builtin_constant_p (__n) &&
(__n) > 0)) && __builtin_constant_p ((((long unsigned int) (__n)) <= ((sz)) /
((sizeof (char))))) && (((long unsigned int) (__n)) <= ((sz)) / ((sizeof
(char)))))))
    return __fgets_alias (__s, __n, __stream);
  if ((((__typeof (__n)) 0 < (__typeof (__n)) -1 || (__builtin_constant_p (__n)
&& (__n) > 0)) && __builtin_constant_p ((((long unsigned int) (__n)) <= (sz) /
(sizeof (char)))) && !(((long unsigned int) (__n)) <= (sz) / (sizeof (char)))))
    return __fgets_chk_warn (__s, sz, __n, __stream);
  return __fgets_chk (__s, sz, __n, __stream);
}

--
December 24, 2023
https://issues.dlang.org/show_bug.cgi?id=24297

--- Comment #4 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Reduced:

#include <stdio.h>

int foo()
{
        int __n;
        return ((__typeof (__n)) 0 );
}

Maybe just needs a #define __typeof typeof?

--
December 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24297

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15957 "fix Issue 24297 - ImportC incompatible with glibc _FORTIFY_SOURCE" fixing this issue:

- fix Issue 24297 - ImportC incompatible with glibc _FORTIFY_SOURCE

https://github.com/dlang/dmd/pull/15957

--
December 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24297

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15957 "fix Issue 24297 - ImportC incompatible with glibc _FORTIFY_SOURCE" was merged into master:

- 7ce929a02cd315abd8f0e420327625164a9c0c97 by Walter Bright:
  fix Issue 24297 - ImportC incompatible with glibc _FORTIFY_SOURCE

https://github.com/dlang/dmd/pull/15957

--