Bug 19141 - #pragma misbehavior with -Werror
Summary: #pragma misbehavior with -Werror
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.3
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-23 16:13 UTC by Ted Burghart
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Burghart 2004-12-23 16:13:30 UTC
Whether "#pragma once" is or is not deprecated is not the issue.  Rather, the 
problem is that GCC's behavior since it was deprecated is inappropriate for 
writing portable code and arguably violates the intent of the C (9899-1999 
6.10.6) and C++ (14882-1998 16.6) language specifications.

While the specs dictate that recognized pragma directives behave in an 
implementation-defined manner, they also dicatate that unrecognized pragma 
directives are ignored.  It seems that GCC's behavior regarding (deprecated) 
#pragma once falls in a grey area between the two, and it could be argued that 
the behavior should be that of an unrecognized pragma since the directive has 
no effect.

Unfortunately, the behavior of issuing a warning regarding #pragma once, with 
no means to turn it off, breaks code portability while offering no benefit.  If 
the -Werror switch is turned on (considered good practice by many) in concert 
with reasonable warning levels, legitimate portable code fails to compile 
because of this behavior.

Whatever your personal feelings toward #pragma once, it is arrogant (at best) 
to effectively preclude its presence in header files.  Many, many compilers 
recognize this pragma and (claim to) do something useful with it.  If GCC 
chooses not to use it, that's fine, but issuing a warning that can't be turned 
off over an ineffectual, deprecated pragma directive certainly appears to 
violate the spirit of the language specifications.
Comment 1 Andrew Pinski 2004-12-23 16:23:48 UTC
Well it is undeprecated for 3.4.0 so in that way it is fixed so closing as such.

This will not be fixed in 3.3.x as it was a rewrite of libcpp (the preprocessor) handling of files which 
fixed it.  So i am just closing as fixed for 3.4.0.