rfg@MCC.COM (Ron Guilmette) (04/23/89)
If you compile the following code with -Wall, you will only get one warning to the effect that "structure has no members" this appears to be inconnsistant because neither of the two have any members, so there should be *two* warning messages. ------------------------------------------------------------------- struct base { }; struct derived : public base { }; ---------------------------------------------------------------------
pelle@eva.slu.se (OVE EWERLID) (04/23/89)
In article <8904222123.AA22649@riunite.aca.mcc.com>, rfg@MCC.COM (Ron Guilmette) writes: > If you compile the following code with -Wall, you will only get one > warning to the effect that "structure has no members" this appears > to be inconnsistant because neither of the two have any members, > so there should be *two* warning messages. I agree that the warnings but also the error messages suffer from a certain degree of inconnsistency. (Cosmetic though) We also have: foo (int a) { int a; //...... } We ought to get a warning that the argument is being shadowed! (at least when the -Wall flag is given) or is this valid C++? also: foo () { a=b+b+b+b; } Don't know if this exact example suffers from the fact, that although the error message states that b is to be reported only once as undefined it is not. (Inconnsistent?) As I haven't got access to g++ on this machine I can't state an exact example. As I se this effect regularly it ought to be well known. and: foo() { double a; int b; b=a; } Here we get a warning. This is as it should be as the function is ambigous as there exist many ways to map a float to an integer. However, one should be able to specify what kind of mapping the compiler uses. One could for instance have a flag that indicated some handy mapping. If this flag is specified the compiler can and should be silent as the mapping no longer is ambigous. The two mappings that springs up is rounding and truncating. There is a gain connected with the mapping method. On a sun3 with FPU there exist two mappings in the FPU, each mapping has its own instruction. Now, if you need the method that isn't present(rounding) and don't want to define a macro to do the job as this is inefficient you gotta patch the assembler output. Simply replace the trunc instruction with the desired rounding ditto. In tight loops the gain can be huge. (Ofcourse you can alter the specific line in md, but it is still quite messy) Nice if an abillity to choose method was embedded in the compiler! As stated, the above is cosmetics at this stage of g++........