public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Strange Warnings
@ 2001-09-19 13:40 Frank Klemm
  2001-09-20 18:04 ` Zack Weinberg
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Klemm @ 2001-09-19 13:40 UTC (permalink / raw)
  To: gcc

Code --------------------------------------------

#include <math.h>

double  TEST_RUN ( unsigned int ms )
{
    static float           A [1000];
    int                    ret = 0;
    size_t                 i;

    ms *= 1000;
    while ( ms-- ) {
        for ( i = 0; i < 1000; i++ )
            ret += (int) floorf (A[i]);                     <------------
    }

    return (double) ret;
}


Warning while compiling -------------------------------

test-0003-inc.c: In function 'test_0003_run':
test-0003-inc.c:12: warning: passing arg 1 of 'floorf' as 'float' rather than 'double' due to prototype
test-0003-inc.c:12: warning: cast does not match function type


Remarks ------------------------------------------------

Warning 1 is not very useful, it is so little useful so that it disturbs.
Warning 2 I do not understand.

-- 
Frank Klemm

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange Warnings
  2001-09-19 13:40 Strange Warnings Frank Klemm
@ 2001-09-20 18:04 ` Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2001-09-20 18:04 UTC (permalink / raw)
  To: Frank Klemm; +Cc: gcc

On Wed, Sep 19, 2001 at 10:37:58PM +0200, Frank Klemm wrote:
> 
> test-0003-inc.c: In function 'test_0003_run':
> test-0003-inc.c:12: warning: passing arg 1 of 'floorf' as 'float' rather than 'double' due to prototype

Don't use -Wconversion.  It is only useful for shakedown compiles
after converting an old K+R program to ANSI prototypes.

> test-0003-inc.c:12: warning: cast does not match function type

What switch did you use to get this warning?

zw

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Strange warnings
  1999-05-05  1:12 Strange warnings Ryszard Kabatek
  1999-05-05  5:45 ` Gabriel Dos_Reis
@ 1999-05-31 21:36 ` Ryszard Kabatek
  1 sibling, 0 replies; 7+ messages in thread
From: Ryszard Kabatek @ 1999-05-31 21:36 UTC (permalink / raw)
  To: egcs

In the sample below the class X should have a standard constructor
generated by the compiler. But I get the following warnings:

# eg++ x.cc
x.cc:6: warning: `class X' only defines private constructors and has no
friends
x.cc: In function `static class X * X::create()':
x.cc:5: no matching function for call to `X::X ()'
x.cc:3: candidates are: X::X(const X &)


The first warning I get too if I define a private standard constructor.
But there is a static function, that creates new instances of X,
class X does not need friend functions or classes.


# cat x.cc

class X {
    X(const X&);
  public:
    static X* create() {return new X();}
};

int main(int argc, char* argv)
{
  X* p = X::create();
  delete p;
}


Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange warnings
  1999-05-05  5:45 ` Gabriel Dos_Reis
@ 1999-05-31 21:36   ` Gabriel Dos_Reis
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Dos_Reis @ 1999-05-31 21:36 UTC (permalink / raw)
  To: kabatek; +Cc: egcs, egcs-bugs

Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de> writes:

| In the sample below the class X should have a standard constructor
| generated by the compiler. But I get the following warnings:
| 
| # eg++ x.cc
| x.cc:6: warning: `class X' only defines private constructors and has no
| friends
| x.cc: In function `static class X * X::create()':
| x.cc:5: no matching function for call to `X::X ()'
| x.cc:3: candidates are: X::X(const X &)

EGCS gets it right. The Standard says:

12.1/5
---
  A default constructor for a class X is a constructor of class X that 
  can be called without an argument. If there is no user-defined
  constructor for class X, a default constructor is implicitly
  declared ...
---

Since you declared X::X(const X&), the default constructor is not
implicitly declared and it is up to you do so and give it a semantic.


| The first warning I get too if I define a private standard constructor.
| But there is a static function, that creates new instances of X,
| class X does not need friend functions or classes.

It is two way :-) : it can be helpful and quite inappropriate.

-- Gaby

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange warnings
  1999-05-05  1:12 Strange warnings Ryszard Kabatek
@ 1999-05-05  5:45 ` Gabriel Dos_Reis
  1999-05-31 21:36   ` Gabriel Dos_Reis
  1999-05-31 21:36 ` Ryszard Kabatek
  1 sibling, 1 reply; 7+ messages in thread
From: Gabriel Dos_Reis @ 1999-05-05  5:45 UTC (permalink / raw)
  To: kabatek; +Cc: egcs, egcs-bugs

Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de> writes:

| In the sample below the class X should have a standard constructor
| generated by the compiler. But I get the following warnings:
| 
| # eg++ x.cc
| x.cc:6: warning: `class X' only defines private constructors and has no
| friends
| x.cc: In function `static class X * X::create()':
| x.cc:5: no matching function for call to `X::X ()'
| x.cc:3: candidates are: X::X(const X &)

EGCS gets it right. The Standard says:

12.1/5
---
  A default constructor for a class X is a constructor of class X that 
  can be called without an argument. If there is no user-defined
  constructor for class X, a default constructor is implicitly
  declared ...
---

Since you declared X::X(const X&), the default constructor is not
implicitly declared and it is up to you do so and give it a semantic.


| The first warning I get too if I define a private standard constructor.
| But there is a static function, that creates new instances of X,
| class X does not need friend functions or classes.

It is two way :-) : it can be helpful and quite inappropriate.

-- Gaby

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Strange warnings
@ 1999-05-05  1:12 Ryszard Kabatek
  1999-05-05  5:45 ` Gabriel Dos_Reis
  1999-05-31 21:36 ` Ryszard Kabatek
  0 siblings, 2 replies; 7+ messages in thread
From: Ryszard Kabatek @ 1999-05-05  1:12 UTC (permalink / raw)
  To: egcs

In the sample below the class X should have a standard constructor
generated by the compiler. But I get the following warnings:

# eg++ x.cc
x.cc:6: warning: `class X' only defines private constructors and has no
friends
x.cc: In function `static class X * X::create()':
x.cc:5: no matching function for call to `X::X ()'
x.cc:3: candidates are: X::X(const X &)


The first warning I get too if I define a private standard constructor.
But there is a static function, that creates new instances of X,
class X does not need friend functions or classes.


# cat x.cc

class X {
    X(const X&);
  public:
    static X* create() {return new X();}
};

int main(int argc, char* argv)
{
  X* p = X::create();
  delete p;
}


Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Strange Warnings...
@ 1998-08-17 17:41 Sebastian Ritterbusch
  0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Ritterbusch @ 1998-08-17 17:41 UTC (permalink / raw)
  To: egcs

Do the egcs (-O3 -g -Wall -Winline) warnings 

interval.inl:4: warning: \x03lass real * this' might be used
uninitialized in this function
interval.inl:4: warning: variable \x03lass real * this' might be clobbered by
\fongjmp' or \x16fork'

mean that i am in trouble?

interval.inl:
    3 inline interval::interval(const real &a,const real &b)
    4 {
    5    inf=a,sup=b;
    6 }
   
(class real is the same as double, its only data is a double)

How could *this ever be uninitialized in a member function? 

(This warning appears also in different member functions not only in 
constructors...)

I hope this really is a problem of the compiler... 

Ciao, Sebastian.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-09-20 18:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-19 13:40 Strange Warnings Frank Klemm
2001-09-20 18:04 ` Zack Weinberg
  -- strict thread matches above, loose matches on Subject: below --
1999-05-05  1:12 Strange warnings Ryszard Kabatek
1999-05-05  5:45 ` Gabriel Dos_Reis
1999-05-31 21:36   ` Gabriel Dos_Reis
1999-05-31 21:36 ` Ryszard Kabatek
1998-08-17 17:41 Strange Warnings Sebastian Ritterbusch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).