Bug 1473934 - Can't include <sys/quota.h> before <iostream>
Summary: Can't include <sys/quota.h> before <iostream>
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 26
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-22 14:48 UTC by Jyrki Havia
Modified: 2017-09-18 12:42 UTC (History)
34 users (show)

Fixed In Version: kernel-4.14.0-0.rc0.git3.1.fc28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-09-18 12:42:09 UTC
Type: Bug
Embargoed:


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 14:48 UTC, Jyrki Havia
no flags Details

Description Jyrki Havia 2017-07-22 14:48:04 UTC
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 19:57:57 UTC
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 22:09:35 UTC
That means it is a glibc bug caused by
commit 4d728087ef8cc826b05bd21d0c74d4eca9b1a27d
Author: Florian Weimer <fweimer>
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 14:32:17 UTC
I posted a kernel patch: http://marc.info/?l=linux-fsdevel&m=150246173513558

Comment 4 Florian Weimer 2017-09-18 12:42:09 UTC
Fixed in the kernel with this upstream commit:

commit 34fc75bfc616f1c1fbab56508c3f48f4b97c97ea
Author: Florian Weimer <fweimer>
Date:   Fri Aug 11 16:24:15 2017 +0200

    uapi/linux/quota.h: Do not include linux/errno.h
    
    linux/errno.h is very sensitive to coordination with libc headers.
    Nothing in linux/quota.h needs it, so this change allows using
    this header in more contexts.


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