Bug 1473934 - Can't include <sys/quota.h> before <iostream>
Can't include <sys/quota.h> before <iostream>
Status: NEW
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
26
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Carlos O'Donell
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-22 10:48 EDT by Jyrki Havia
Modified: 2017-08-11 10:32 EDT (History)
12 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Log of two compilation runs with the example code. First OK, second fails. (2.82 KB, text/plain)
2017-07-22 10:48 EDT, Jyrki Havia
no flags Details

  None (edit)
Description Jyrki Havia 2017-07-22 10:48:04 EDT
Created attachment 1302790 [details]
Log of two compilation runs with the example code. First OK, second fails.

Description of problem:
On just installed (2 hours ago) Fedora 26
include file <sys/quota.h> pollutes g++ environment
so that including <iostream> after <sys/quota.h> produces error.

Version-Release number of selected component (if applicable):
gcc version 7.1.1 20170622 (Red Hat 7.1.1-3) (GCC) 

How reproducible:
Compile following snippet by
[havia@game mailquota]$ g++ err.cpp   -c -DERROR_ON=0
  All fine

[havia@game mailquota]$ g++ err.cpp   -c -DERROR_ON=1
  Won't compile

--- clip ---
#if ERROR_ON == 1
#include <sys/quota.h>
#include <iostream>
#else
#include <iostream>
#include <sys/quota.h>
#endif

int func(void) { return 0; }
--- clip ---

Steps to Reproduce:
1. See test code above.

Actual results:
Compilation error

Expected results:
Compilation without errors.

Additional info:
Comment 1 Jonathan Wakely 2017-07-23 15:57:57 EDT
This isn't a GCC bug. This also fails:

#include <sys/quota.h>
#include <errno.h>
#ifndef ERANGE
#error no ERANGE
#endif

This is because <sys/quota.h> includes <linux/errno.h> so when <bits/errno.h> includes it again (after doing #undef ERANGE) it doesn't define anything.
Comment 2 Jakub Jelinek 2017-07-23 18:09:35 EDT
That means it is a glibc bug caused by
commit 4d728087ef8cc826b05bd21d0c74d4eca9b1a27d
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Sep 1 15:53:13 2016 +0200

    Base <sys/quota.h> on Linux kernel headers [BZ #20525]
    
    Macros which are also defined in <linux/quota.h> are removed, and
    <linux/quota.h> is included instead.
    
    This commit cleans up the definition of fs_to_dq_blocks and struct
    dqblock and struct dqinfo, too.

Either sys/quota.h should ensure linux/errno.h is not included, or should include <errno.h> first or something different that will work.
Comment 3 Florian Weimer 2017-08-11 10:32:17 EDT
I posted a kernel patch: http://marc.info/?l=linux-fsdevel&m=150246173513558

Note You need to log in before you can comment on or make changes to this bug.