Archive

Posts Tagged ‘Standard’

A fault in the C Standard or existing compilers?

February 24th, 2009 Derek-Jones No comments

Software is not the only entity that can contain faults. The requirements listed in a specification are usually considered to be correct, almost by definition. Of course the users of software implementing a specification may be unhappy with the behavior specified and wish that some alternative behavior occurred. A cut and dried fault occurs when two requirements conflict with each other.

The C Standard can be read as a specification for how C compilers should behave. Despite over 80 man years of effort and the continued scrutiny of developers over 20 years, faults continue to be uncovered. The latest potential fault (it is possible that the fault actually occurs in many existing compilers rather than the C Standard) was brought to my attention by Al Viro, one of the Sparse developers.

The issue involved the following code (which I believe the standard considers to be strictly conforming, but all the compilers I have tried disagree):

int (*f(int x))[sizeof x];  // A prototype declaration
 
int (*g(int y))[sizeof y]  // A function definition
{
return 0;
}

These function declarations are unusual in that their return type is a pointer to an array of integers, a type rarely encountered in this context (the original question involved a return type of pointer to function returning … and was more complicated).

The specific issue was the scope of the parameter (i.e., x and y), is the declaration still in scope at the point that the second occurrence of the identifier is encountered?

As a principle I think that the behavior, whatever it turns out to be, should be the same in both cases (neither the C standard or its rationale state such a principle).

Taking the function prototype case first:

The scope of the parameter x “… terminates at the end of the function declarator.” (sentence 409).

and does function prototype scope include the return type (the syntax calls the particular construct a declarator and there are at least two of them, one nested inside the other, in a function prototype declaration)?

Sentence 1592 says Yes, but sentence 279 and 1845 say No.

None of these references are normative references (standardize for definitive).

Moving on to the function definition case:

Where does the scope of the parameter x begin (sentence 418)?
… scope that begins just after the completion of its declarator.

and where does the scope end (sentence 408)?
… which terminates at the end of the associated block.

and what happens between the beginning and ending of the scope (sentence 412)?
Within the inner scope, the identifier designates the entity declared in the inner scope;

This looks very straight forward, there are no ‘gaps’ in the scope of the parameter definition appearing in a function definition. Consistency with the corresponding function prototype case requires that function declarator be interpreted to include the return type.

There is a related discussion involving a previous Defect Report 345 submitted a while ago.

The problem is that many existing compilers do not treat parameter scope in this way. They operate as-if there was a ‘gap’ in the parameter scope of function definition (probably because the code implementing this functionality is shared with that implementing function prototypes, which have been interpreted to not include the return type).

What happens next? Probably lots of discussion on the C Standard email reflector. Possible outcomes include somebody finding wording that requires a ‘gap’ in the scope of parameters in function definitions, it agreed that such a gap ought to be specified by the standard (because this is how existing code behaves because this is how compilers operate), or that the standard is correct as is and any compiler that behaves differently needs to be fixed.

C++ goes for too big to fail

December 8th, 2008 Derek-Jones No comments

If you believe the Whorfian hypothesis that language effects thought, even in one of its weaker forms, then major changes to a programming language will effect the shape of the code its users write.

I was at the first International C++ Standard meeting in London during 1991 and coming from a C Standard background I could not believe the number of new constructs being invented (the C committee had a stated principle that a construct be supported by at least one implementation before it be considered for inclusion in the standard; ok, this was not always followed to the letter). The C++ committee members continued to design away, putting in a huge amount of effort, and the document was ratified before the end of the century.

The standard is currently undergoing a major revision and the amount of language design going on puts the original committee to shame. With over 1,300 pages in the latest draft nobodies favorite construct is omitted. The UK C++ panel has over 10 people actively working on producing comments and may produce over 1,000 on the latest draft.

With so many people committed to the approach being taken in the development of the revised C++ Standard its current direction is very unlikely to change. The fact that most ‘real world’ developers only understand a fraction of what is contained in the existing standard has not stopped it being very widely used and generally considered as a ’success’. What is the big deal over a doubling of the number of pages in a language definition, the majority of developers will continue to use the small subset that they each individually have used for years.

The large number of syntactic ambiguities make it is very difficult to parse C++ (semantic information is required to resolve the ambiguities and the code to do this is an at least an order of magnitude bigger than the lexer+parser). This difficulty is why there are so few source code analysis tools available for C++, compared to C and Java which are much much easier to parse. The difficulty of producing tools means that researchers rarely analyse C++ code and only reasonably well funded efforts are capably of producing worthwhile static analysis tools.

Like many of the active committee members I have mixed feelings about this feature bloat. Yes it is bad, but it will keep us all actively employed on interesting projects for many years to come. As the current financial crisis has shown, one of the advantages of being big and not understood is that you might get to being too big to fail.

Will IEEE 754 become a fringe representation?

December 1st, 2008 Derek-Jones No comments

Many people believe that with a few historical exceptions the IEEE 754 standard has won the floating-point value bit-representation battle.  What these people have forgotten is that money rules; customers are willing to ditch standards if it increases profit. FPGA devices can be configured to perform float-point operations faster and more cheaply than commodity cpus.

Making optimal use of a FPGA may require using a radix of 4 and for the time being automatically convert back and forth between an external 754 radix-2 representation.  In those cases where multiplication/division operations are more common than addition/subtraction use of a logarithmic number system has performance benefits.  For specialist scientific calculations (where cpu time is measured in days) purpose built FPGA devices are the path to significant performance improvements.  In many mass market applications the full power of a 32-bit representation is not needed and a representation using fewer bits does an acceptable job using less powerful (ie, cheaper) hardware.

Customer demand for higher performance and lower cost will push vendors to deliver purpose designed products.  IEEE 754 may be the floating-point representation that people without spending power use because it was once  designed into cpus and vendors are forced to continue to support it for backwards compatibility.

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com best way to use cialis

next day delivery cialis

discount drug propecia

order propecia

buy cheap generic levitra

canada viagra generic

how much does cialis cost

generic propecia fda approved

discount levitra rx

levitra in canada

fda levitra

lowest price for propecia

canadian viagra 50mg

canada levitra

cheap propecia online prescription

once a day viagra

cialis from canada

buy cialis in usa

buying propecia

buy canada levitra

natural viagra

buying cialis

levitra online

generic levitra online

buy viagra china

levitra sales uk

cheap fast levitra

cheap prescription propecia

canada online pharmacy propecia

levitra tabs

cialis price 100 mg

cialis daily in canada

obtain viagra without prescription

cheapest prices for viagra

generic propecia alternative

cialis tablets foreign

cost levitra low

canada cheap propecia

getting cialis from canada

buy propecia cheap

overnight delivery viagra

cialis en mexico

cialis 100 mg

cheapest propecia uk

cialis 5 mg italia

combine cialis and levitra

indian viagra

cialis quick shipment

generic propecia for sale

cialis purchase

order prescription propecia

cialis one a day

online propecia prescription

cheap cialis

cheap levitra

buy cialis canada

levitra mail order

canadian pharmacy viagra

cheapest viagra usa

levitra pill

buy viagra online cheap us

herbal propecia

cheapest price propecia cheap

levitra cost

buy generic cialis

brand name cialis overnight

lowest priced propecia

50 mg cialis

cialis pharmacy

buy levitra online viagra

mexico pharmacy cialis

levitra canadian

cialis next day

bio viagra herbal

generic propecia sale

buying viagra in canada

generic levitra canada

levitra mg

get levitra

i need to buy propecia

buy propecia online prescription

cialis uk

5 mg original brand cialis

brand cialis for sale

canadian pharmacy discount code viagra

low cost levitra

cialis overnight delivery

cheap viagra online

buy propecia online

buy propecia now

levitra buy online

canadian viagra

buy cialis 5 mg

generic viagra canadian

best viagra

indian cialis generic

lowest price propecia

cheap cialis soft

buy viagra without prescription

healthcare canadian pharmacy

mexico levitra

cheap viagra from uk

discount levitra online

cialis daily

levitra cheap fast

cialis delivered overnight

canada propecia prescription

buying levitra online

buy propecia online from usa pharmacy

canadian pharmacy cialis

cialis tablets

cheap levitra prescription

ordering propecia online

buy propecia on line

get cialis online

buy cheapest propecia

best price generic propecia

drug generic propecia

buy real cialis

discount cialis india

buy cialis for daily use

buy viagra online

generic cialis next day shipping

buy online prescription propecia

does generic cialis work

levitra for sale

buy cialis without prescription

generic levitra overnight delivery

buy levitra online from canada

cheapest propecia sale uk

levitra order prescription

levitra next day delivery

cialis refractory

order levitra online

cialis buy overnight

how much cialis

brand viagra over the net

can i get viagra in mexico

levitra viagra online

best price propecia

cialis soft pills

order cheapest propecia online

how to buy cialis in canada

cialis 5 mg buy

buy propecia online pharmacy

generic propecia online pharmacy

canadian viagra and healthcare

get levitra online

discount propecia propecia

internet pharmacy propecia

cialis professional 20 mg

buy cialis fedex shipping

online cheap viagra

buy prescription propecia without

buy propecia in the uk

once daily cialis

cialis professional 100 mg

buy cialis online canada

cialis from mexico

cialis dosage mg

cialis and diarrhea

buy propecia prescriptions online

cialis daily dosage pharmacy

discount propecia rx

buy levitra overnight

cialis price in canada

order cheap propecia

levitra low price

canadian pharmacies cialis

generic viagra made in india

canada viagra pharmacies scam

cheap viagra canada or india

levitra online prescription

cialis discount

5 mg daily cialis

online levitra

discount levitra purchase

best price levitra

lowest price propecia best

generic cialis sale

genuine cialis pills

female viagra pills

canada generic propecia

online pharmacy propecia viagra

generic viagra canada

canadian online pharmacy cialis

indian generic levitra

cheap propecia no prescription

buy cheap levitra online

cheap canadian viagra

cialis alternative

bestellen levitra online

overnight delivery cialis

online generic cialis 100 mg

cheap propecia uk

canadian healthcare pharmacy

buy viagra mexico

canada meds viagra

online viagra gel to buy

name brand cialis

low cost propecia

cialis 50 mg

cialis prescription

levitra online sales

cost of viagra

generic viagra india

cialis fast delivery

cheap order prescription propecia

buy dosages levitra

indian cialis

levitra where to buy

low price levitra

cialis transdermal

china viagra

levitra now online

lowest cost levitra

buy levitra vardenafil

buy fast propecia

how to get viagra

cialis and canada custom

buy branded viagra

how much is viagra

cheap propecia 5mg

generic viagra made in usa

buy cialis once daily

cialis generic 100 mg

how much to buy viagra in pounds

cialis and ketoconazole

buy levitra uk

canadian propecia rx

cialis on women

get cialis

buying propecia online

canadian drugs propecia

lowest propecia prices

generic levitra purchase

generic propecia 5mg

buying generic cialis mexico rx

buying cialis soft tabs 100 mg

ganeric cialis

cialis headaches

buy levitra online no prescription

canada online pharmacy levitra

get propecia online pharmacy

buy propecia without prescription

cialis fast delivery usa

discount generic propecia

levitra discount

generic cialis from india

cost of propecia

levitra online overnight delivery

levitra online no prescription

cheapest propecia prescription

cialis vs levitra

online pharmacy propecia renova

lowest price on non generic levitra

buy can from i propecia who

online propecia prescriptions

cialis 100 mg generic

best price cialis

buy generic viagra india rx

levitra 10mg

cialis price

buy viagra

cialis cheap

brand viagra professional

mail order propecia

buy generic levitra

buy cheap levitra

levitra online us

cheapest viagra online

lowest propecia prices in canada

cialis next day delivery

cost of daily cialis

buy cheap generic propecia

discount us propecia

lowest propecia 1 mg

daily dosage cialis

generic cialis soft tabs

gele viagra

buy propecia canada

generic viagra online

cheap cialis from india

how to get cialis in canada

generic viagra 100 mg

buy propecia where

best price for generic cialis

buying generic propecia

hydrochlorothiazide cialis

generic propecia effective

cheap propecia online

buy cialis usa

canadian pharmacy

lowest price levitra

cheap levitra uk

buy levitra us

cialis by mail

cialis 5 mg

brand name cialis

low cost canadian viagra