Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000848 [1003.1(2013)/Issue7+TC1] Shell and Utilities Objection Error 2014-06-19 15:17 2019-06-10 08:54
Reporter rhansen View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Richard Hansen
Organization BBN
User Reference
Section c99, make
Page Number 2512, 2945
Line Number 80970-80975, 97465
Interp Status Approved
Final Accepted Text Note: 0002269
Summary 0000848: make defaults CFLAGS to -O, but c99 requires a level
Description The default value of CFLAGS in make is '-O', but the c99 '-O' option requires an optlevel option-arguement.

see http://thread.gmane.org/gmane.comp.standards.posix.austin.general/9508 [^]
Desired Action to be added in a bug note (allow a missing level? change the default? if change the default, what should the default be?)
Tags tc2-2008
Attached Files

- Relationships

-  Notes
(0002269)
rhansen (manager)
2014-06-19 16:51
edited on: 2014-06-26 15:50

Interpretation response
------------------------
The standard states that by default make shall achieve results that are the same as CFLAGS=-O, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
The specification for the c99 utility does not support -O without an option-argument. In addition, if a subsequent argument is provided, the argument will be (erroneously) interpreted as an optimization level.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
On page 2945 line 97465 change:

    CFLAGS=-O

to:

    CFLAGS=-O 1

On page 2949 line 97621 change:

    c99 −c −O $*.c

to:

    c99 −c −O 1 $*.c

On page 2949 line 97624 change:

    c99 −c −O $<

to:

    c99 −c −O 1 $<

(0002270)
mdempsky (reporter)
2014-06-19 18:10

Two thoughts:

1. Currently, a conforming application could override CC to specify a custom compiler and expect that CFLAGS should still be set to just "-O" (or not set at all). Alternative "-O optlevel" flags might not have the same semantics. E.g., "gcc" doesn't support "-O 1".

2. Also, since "-O 1" doesn't have any specified semantics for the c99 utility, so why specify "-O 1" at all?

Perhaps instead simply specify that if CFLAGS is set by the system, it will be a "-O" option suitable for use with the system provided c99 utility?
(0002271)
joerg (reporter)
2014-06-20 09:19
edited on: 2014-06-20 09:20

Historically, C-Compilers did not have an optimization level argument to the
-O option, so I would guess that all existing compilers support -O without
argument.

The SunPro compiler even does not support -O space <level>:

LC_ALL=C cc -O 2 t.c
"t.c", line 2: warning: old-style declaration or incorrect type for: main
"t.c", line 3: warning: implicit function declaration: printf
ld: fatal: file 2: open failed: No such file or directory
ld: fatal: file processing errors. No output written to a.out

LC_ALL=C c89 -O 1 t.c
c89: Warning: option -1 passed to ld
usage: ld [-6:abc:d:e:f:h:il:mo:p:rstu:z:B:CD:F:GI:L:M:N:P:Q:R:S:VW:Y:?] file(s)
        [-64] enforce a 64-bit link-edit


so the current standard requirements seems to be wrong.

Interestingly, c99 behaves as the standard requires:

LC_ALL=C c99 -O t.c
c99: Warning: illegal option -Ot.c
usage: c99 [ options] files. Use 'c99 -flags' for details

so it seems that a bug in the standard created a hard to solve situation.

(0002272)
geoffclare (manager)
2014-06-20 09:26

The semantics of c99 -O 1 are not completely unspecified; c99 is required to set the level of code optimization to level 1. It is only the nature of level 1 optimization that is unspecified. I assume this is to allow not just for differing types of optimization but also for the possibility that some compilers might not support optimization at all, in which case -O 1 would be the same as -O 0.

It is also worth noting that the macro defaults for the make utility are not literal requirements. Line 97447 says "The default rules for make shall achieve results that are the same as if the following were used." Some implementations seem to have taken advantage of this to have an empty CFLAGS by default (which is fine provided c99 without -O behaves the same as c99 -O 1).

So I don't see any problem with making the change Richard proposed in Note: 0002269.
(0002273)
joerg (reporter)
2014-06-20 09:34

On Solaris, the situation is that the standard compiler cc does not
accept an otimization level separated by a space and c99 does not work
if the space is omitted.

make only causes no problems as it does not define optimization
to be turned on by default.
(0002288)
ajosey (manager)
2014-06-27 11:09

Interpretation proposed June 27 2014
(0002332)
ajosey (manager)
2014-08-05 13:18

Interpretation approved 5 August 2014

- Issue History
Date Modified Username Field Change
2014-06-19 15:17 rhansen New Issue
2014-06-19 15:17 rhansen Name => Richard Hansen
2014-06-19 15:17 rhansen Organization => BBN
2014-06-19 15:17 rhansen Section => c99, make
2014-06-19 15:17 rhansen Page Number => 2512, 2945
2014-06-19 15:17 rhansen Line Number => 80970-80975, 97465
2014-06-19 16:51 rhansen Note Added: 0002269
2014-06-19 18:10 mdempsky Note Added: 0002270
2014-06-20 09:19 joerg Note Added: 0002271
2014-06-20 09:20 joerg Note Edited: 0002271
2014-06-20 09:26 geoffclare Note Added: 0002272
2014-06-20 09:34 joerg Note Added: 0002273
2014-06-26 15:48 rhansen Note Edited: 0002269
2014-06-26 15:50 rhansen Note Edited: 0002269
2014-06-26 15:51 geoffclare Interp Status => Pending
2014-06-26 15:51 geoffclare Final Accepted Text => Note: 0002269
2014-06-26 15:51 geoffclare Status New => Interpretation Required
2014-06-26 15:51 geoffclare Resolution Open => Accepted As Marked
2014-06-26 15:52 geoffclare Tag Attached: tc2-2008
2014-06-27 11:09 ajosey Interp Status Pending => Proposed
2014-06-27 11:09 ajosey Note Added: 0002288
2014-08-05 13:18 ajosey Interp Status Proposed => Approved
2014-08-05 13:18 ajosey Note Added: 0002332
2019-06-10 08:54 agadmin Status Interpretation Required => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker