Mixed optimization and pragma settings cause ‘__open_too_many_args’ compile error

Bug #1392888 reported by Alan Chen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.8 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Sample program below compiles with gcc with no errors, but results with a compile error with g++

g++ version: 4.8.2-19ubuntu1

gcc -O2 prog.c # ok
g++ -O2 prog.c # error

In file included from /usr/include/fcntl.h:279:0,
                 from prog.c:5:
In function ‘int open(const char*, int, ...)’,
    inlined from ‘int main()’ at prog.c:12:40:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:44:28: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more
     __open_too_many_args ();

Sample program:

#pragma GCC optimize ("O0")

#include <fcntl.h>
#include <unistd.h>

int main()
{
 int fd;

 fd = open( "filename", O_RDONLY, 0644);
 if (fd < 0) return 1;

 close(fd);

 return 0;
}

Alan Chen (digikata)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.