Bug 50423 - error: ‘getpid’ was not declared in this scope
Summary: error: ‘getpid’ was not declared in this scope
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-15 17:54 UTC by Jack Howarth
Modified: 2011-09-16 09:34 UTC (History)
0 users

See Also:
Host: x86_64-apple-darwin11
Target: x86_64-apple-darwin11
Build: x86_64-apple-darwin11
Known to work:
Known to fail:
Last reconfirmed:


Attachments
bzip2 compressed preprocessed source for common/semaphore.cc (58.95 KB, application/x-bzip2)
2011-09-15 17:54 UTC, Jack Howarth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Howarth 2011-09-15 17:54:45 UTC
Created attachment 25294 [details]
bzip2 compressed preprocessed source for common/semaphore.cc

Current gcc trunk produces a compile time error for common/semaphore.cc in xplor-nih 2.27...

g++-fsf-4.7 -c semaphore.cc -O3 -ffast-math -funroll-loops -g -fpermissive  -DX_MMAP_FLAGS=0 -DFORTRAN_INIT -fno-common  -DDARWIN -D_REENTRANT -DNDEBUG  -I/Users/howarth/xplor-nih-2.27/common/ -I/Users/howarth/xplor-nih-2.27/arch/Darwin_11_x86_64/include -I/Users/howarth/xplor-nih-2.27/CDSlib -I/Users/howarth/xplor-nih-2.27/intVar -I/Users/howarth/xplor-nih-2.27/pcre -DCPLUSPLUS -DUSE_CDS_NAMESPACE -I/Users/howarth/xplor-nih-2.27/common/ -I/Users/howarth/xplor-nih-2.27/arch/Darwin_11_x86_64/include
semaphore.cc: In constructor ‘CDS::Semaphore::Semaphore(bool)’:
semaphore.cc:111:30: error: ‘getpid’ was not declared in this scope
semaphore.cc: In destructor ‘CDS::Semaphore::~Semaphore()’:
semaphore.cc:124:36: error: ‘getpid’ was not declared in this scope
semaphore.cc:126:9: warning: deleting ‘void*’ is undefined [enabled by default]

which doesn't occur with gcc-4_6-branch...

[MacPro:~/xplor-nih-2.27/common/bin.Darwin_11_x86_64] howarth% g++-fsf-4.6  -c semaphore.cc -O3 -ffast-math -funroll-loops -g -fpermissive  -DX_MMAP_FLAGS=0 -DFORTRAN_INIT -fno-common  -DDARWIN -D_REENTRANT -DNDEBUG  -I/Users/howarth/xplor-nih-2.27/common/ -I/Users/howarth/xplor-nih-2.27/arch/Darwin_11_x86_64/include -I/Users/howarth/xplor-nih-2.27/CDSlib -I/Users/howarth/xplor-nih-2.27/intVar -I/Users/howarth/xplor-nih-2.27/pcre -DCPLUSPLUS -DUSE_CDS_NAMESPACE -I/Users/howarth/xplor-nih-2.27/common/ -I/Users/howarth/xplor-nih-2.27/arch/Darwin_11_x86_64/include
semaphore.cc: In destructor ‘CDS::Semaphore::~Semaphore()’:
semaphore.cc:126:9: warning: deleting ‘void*’ is undefined [enabled by default]
Comment 1 Jack Howarth 2011-09-15 17:57:08 UTC
Attached bzip2 compressed preprocessed source for common/semaphore.cc reproduces this issue...

[MacPro:~/xplor-nih-2.27/common/bin.Darwin_11_x86_64] howarth% g++-fsf-4.7 -c semaphore.ii -O3 -ffast-math -funroll-loops -g -fpermissive -DX_MMAP_FLAGS=0 -DFORTRAN_INIT -fno-common -DDARWIN -D_REENTRANT -DNDEBUGsemaphore.cc: In constructor ‘CDS::Semaphore::Semaphore(bool)’:semaphore.cc:111:30: error: ‘getpid’ was not declared in this scope
semaphore.cc: In destructor ‘CDS::Semaphore::~Semaphore()’:
semaphore.cc:124:36: error: ‘getpid’ was not declared in this scope
semaphore.cc:126:9: warning: deleting ‘void*’ is undefined [enabled by default]
Comment 2 Jack Howarth 2011-09-15 17:57:45 UTC
Note that -fpermissive doesn't eliminate the regression.
Comment 3 Andrew Pinski 2011-09-15 18:01:34 UTC
This is expected you are not including unistd.h in your source which is required if you want to use getpid.  It was a bug before GCC 4.7 that some of the C++ headers included that header file.
Comment 4 Jonathan Wakely 2011-09-16 09:34:31 UTC
As documented at http://gcc.gnu.org/gcc-4.7/changes.html

"Avoid polluting the global namespace by inclusion of <unistd.h>."