← Back to team overview

touch-packages team mailing list archive

[Bug 1392888] [NEW] Mixed optimization and pragma settings cause ‘__open_too_many_args’ compile error

 

Public bug reported:

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;
}

** Affects: gcc-4.8 (Ubuntu)
     Importance: Undecided
         Status: New

** Description changed:

  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:6:
+                  from prog.c:5:
  In function ‘int open(const char*, int, ...)’,
-     inlined from ‘int main()’ at prog.c:12:40:
+     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 ();
- 
+      __open_too_many_args ();
  
  Sample program:
  
  #pragma GCC optimize ("O0")
  
  #include <fcntl.h>
  #include <unistd.h>
  
  int main()
  {
- 	int fd;
+  int fd;
  
- 	fd = open( "filename", O_RDONLY, 0644);
- 	if (fd < 0) return 1;
+  fd = open( "filename", O_RDONLY, 0644);
+  if (fd < 0) return 1;
  
-         close(fd);
+  close(fd);
  
- 	return 0;
+  return 0;
  }

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to gcc-4.8 in Ubuntu.
https://bugs.launchpad.net/bugs/1392888

Title:
  Mixed optimization and pragma settings cause ‘__open_too_many_args’
  compile error

Status in “gcc-4.8” package in Ubuntu:
  New

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;
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1392888/+subscriptions


Follow ups

References