public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30916]  New: Wrong ‘float’ rather than ‘double’ due to prototype warning
@ 2007-02-21 16:26 hermantenbrugge at home dot nl
  2007-02-23 14:08 ` [Bug c/30916] " manu at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hermantenbrugge at home dot nl @ 2007-02-21 16:26 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]

The following code:

void func (float a);
void
func (float a)
{
}

int
main (void)
{
  func (3.0f);
  return 0;
}

Compiled with: gcc -Wconversion bug.c
produces:
bug.c: In function ‘main’:
bug.c:10: warning: passing argument 1 of ‘func’ as ‘float’ rather than ‘double’
due to prototype

I was not expecting this.

When looking at the code in c-typeck.c at line 2473.
I see:
                      /* Warn if any argument is passed as `float',
                         since without a prototype it would be `double'.  */
                      if (formal_prec == TYPE_PRECISION (float_type_node)
                          && type != dfloat32_type_node)

Should the dfloat32_type_node be changed into float_type_node?
When I change this no warning is produced anymore.


-- 
           Summary: Wrong ‘float’ rather than ‘double’ due to prototype
                    warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hermantenbrugge at home dot nl
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30916


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

* [Bug c/30916] Wrong ‘float’ rather than ‘double’ due to prototype warning
  2007-02-21 16:26 [Bug c/30916] New: Wrong ‘float’ rather than ‘double’ due to prototype warning hermantenbrugge at home dot nl
@ 2007-02-23 14:08 ` manu at gcc dot gnu dot org
  2007-02-23 14:21 ` manu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-23 14:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2007-02-23 14:08 -------
What is your version of GCC ?


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30916


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

* [Bug c/30916] Wrong ‘float’ rather than ‘double’ due to prototype warning
  2007-02-21 16:26 [Bug c/30916] New: Wrong ‘float’ rather than ‘double’ due to prototype warning hermantenbrugge at home dot nl
  2007-02-23 14:08 ` [Bug c/30916] " manu at gcc dot gnu dot org
@ 2007-02-23 14:21 ` manu at gcc dot gnu dot org
  2007-02-23 15:26 ` hermantenbrugge at home dot nl
  2007-02-23 16:09 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-23 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from manu at gcc dot gnu dot org  2007-02-23 14:21 -------
I think the warning is correct. If there were no prototype, the value would be
passed as double. Since there is a prototype, the value is passed as float.

That is what -Wconversion warns about up to GCC 4.2 (check the manual for the
description of Wconversion). Since GCC 4.3, those warnings have been moved to
Wtraditional-conversion and Wconversion has a new purpose.

More info: http://gcc.gnu.org/wiki/NewWconversion

(Please, notice that the project is not finished yet, so things may change
before GCC 4.3 is released).

Please, let us know if this answers your question, so we can close this bug
report.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30916


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

* [Bug c/30916] Wrong ‘float’ rather than ‘double’ due to prototype warning
  2007-02-21 16:26 [Bug c/30916] New: Wrong ‘float’ rather than ‘double’ due to prototype warning hermantenbrugge at home dot nl
  2007-02-23 14:08 ` [Bug c/30916] " manu at gcc dot gnu dot org
  2007-02-23 14:21 ` manu at gcc dot gnu dot org
@ 2007-02-23 15:26 ` hermantenbrugge at home dot nl
  2007-02-23 16:09 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: hermantenbrugge at home dot nl @ 2007-02-23 15:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hermantenbrugge at home dot nl  2007-02-23 15:26 -------
Subject: Re:  Wrong =?windows-1252?Q?=91float=92_rather_?=
 =?windows-1252?Q?than_=91double=92_due_to_prototype_warning?=

manu at gcc dot gnu dot org wrote:
> ------- Comment #2 from manu at gcc dot gnu dot org  2007-02-23 14:21 -------
> I think the warning is correct. If there were no prototype, the value would be
> passed as double. Since there is a prototype, the value is passed as float.
>
> That is what -Wconversion warns about up to GCC 4.2 (check the manual for the
> description of Wconversion). Since GCC 4.3, those warnings have been moved to
> Wtraditional-conversion and Wconversion has a new purpose.
>
> More info: http://gcc.gnu.org/wiki/NewWconversion
>
> (Please, notice that the project is not finished yet, so things may change
> before GCC 4.3 is released).
>
> Please, let us know if this answers your question, so we can close this bug
> report.
>   
Yes. This answers the question. Sorry about the noise. I was testing 
this with
gcc version 4.1.1 20070105 (Red Hat 4.1.1-51) on fedora core 6. When I use
gcc version 4.3.0 20070222 (experimental). The problem goes away.
So the problem report can be closed.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30916


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

* [Bug c/30916] Wrong ‘float’ rather than ‘double’ due to prototype warning
  2007-02-21 16:26 [Bug c/30916] New: Wrong ‘float’ rather than ‘double’ due to prototype warning hermantenbrugge at home dot nl
                   ` (2 preceding siblings ...)
  2007-02-23 15:26 ` hermantenbrugge at home dot nl
@ 2007-02-23 16:09 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-23 16:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2007-02-23 16:09 -------
(In reply to comment #3)
> >   
> Yes. This answers the question. Sorry about the noise. I was testing 
> this with
> gcc version 4.1.1 20070105 (Red Hat 4.1.1-51) on fedora core 6. When I use
> gcc version 4.3.0 20070222 (experimental). The problem goes away.
> So the problem report can be closed.
> 

No problem. Thanks for taking the time to report the issue anyway. It is a
frequent confusion. That is why we decided to rename and improve Wconversion.

*** This bug has been marked as a duplicate of 9072 ***


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30916


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

end of thread, other threads:[~2007-02-23 16:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 16:26 [Bug c/30916] New: Wrong ‘float’ rather than ‘double’ due to prototype warning hermantenbrugge at home dot nl
2007-02-23 14:08 ` [Bug c/30916] " manu at gcc dot gnu dot org
2007-02-23 14:21 ` manu at gcc dot gnu dot org
2007-02-23 15:26 ` hermantenbrugge at home dot nl
2007-02-23 16:09 ` manu at gcc dot gnu dot org

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).