Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1986441

Summary: stdio.h undefines __USE_XOPEN_EXTENDED, no definition for FPE_INTDIV
Product: Red Hat Enterprise Linux 8 Reporter: Wade Hampton <wadehamptoniv>
Component: glibcAssignee: glibc team <glibc-bugzilla>
Status: CLOSED NOTABUG QA Contact: qe-baseos-tools-bugs
Severity: low Docs Contact:
Priority: unspecified    
Version: 8.3CC: ahajkova, ashankar, codonell, dj, fweimer, jakub, mnewsome, ohudlick, pfrankli, sipoyare
Target Milestone: betaKeywords: Bugfix
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-08-06 19:03:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Wade Hampton 2021-07-27 14:35:15 UTC
Description of problem:

I am evaluating trapping SIGFPE for an application.  My test program uses sigaction and reads si_code and compares it with FPE_INTDIV. Program works fine with CentOS 7 and below, but does not build on CentOS 8 as it fails to find FPE_INTDIV.  

Version-Release number of selected component (if applicable):

gcc:  8.3.1.5.1
glibc-headers:  2.28.127


How reproducible:  Each time


Steps to Reproduce:
1.  Create test program
2.  Try to compile
3.  

Actual results:
FPE_INTDEV is undefined


Expected results:  it compiles and works


Additional info:

The following program fails to build.  However, if I move the define for __USE_XOPEN_EXTENDED to just before the include for signal.h, it builds fine.

The manual page indicates the _POSIX* include is required for sigaction
and siginfo_t.  

#define _POSIX_C_SOURCE 199309L    /* for siginfo_t per man page */
#define __USE_XOPEN_EXTENDED       /* for FPE_* defines */
#include <stdio.h>
#include <signal.h>

void main() {
  /* this fails to build: */
  if (x == FPE_INTDEV) 
    printf("test\n");
  return(0);
}

Comment 1 Marek Polacek 2021-07-27 15:13:27 UTC
stdio.h is provided by glibc-headers, not gcc.

Comment 2 Carlos O'Donell 2021-08-06 19:03:11 UTC
(In reply to Wade Hampton from comment #0)
> The following program fails to build.  However, if I move the define for
> __USE_XOPEN_EXTENDED to just before the include for signal.h, it builds fine.

You may not define or use double-underscore macros as they are part of the implementation.
 
> The manual page indicates the _POSIX* include is required for sigaction
> and siginfo_t.  

This is called a "feature test macro" which allows your code to use specific features.

See `man 7 feature_test_macros` for more information.

The _POSIX_C_SOURCE controls which POSIX standard is provided by the headers.

In order to use siginfo_t you must have POSIX support equal to or newer than IEEE Std 1003.1b-1993 (>= 199309L).

In order to use FPE_* constants you must *generally* have POSIX support equal to or newer than IEEE 1003.1-2008 (>= 200809L), but there are other standards that also defined these constants.

> #define _POSIX_C_SOURCE 199309L    /* for siginfo_t per man page */
> #define __USE_XOPEN_EXTENDED       /* for FPE_* defines */
> #include <stdio.h>
> #include <signal.h>
> 
> void main() {
>   /* this fails to build: */
>   if (x == FPE_INTDEV) 
>     printf("test\n");
>   return(0);
> }


A simple function would look like this:

#include <stdio.h>
#include <signal.h>
 
void foo(int x) {
  if (x == FPE_INTDIV) 
    printf("test\n");
}

gcc -D_GNU_SOURCE -c test.c

This works because _GNU_SOURCE provides POSIX IEEE 1003.1-2008 (>= 200809L) values e.g. sigaction with siginfo_t and definitions for FPE_INTDIV.

Alternatively:

gcc -D_POSIX_C_SOURCE=200809L -c test.c

I hope this helps!