public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [patch, fortran] PR 47359 - warnings for constant conversion
       [not found] ` <20150531221425.GA34602@troutmask.apl.washington.edu>
@ 2015-06-01  6:34   ` Thomas Koenig
  2015-06-01 13:40     ` Steve Kargl
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Koenig @ 2015-06-01  6:34 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

Hi Steve,

>> The second part catches the case when the user supplies more
>> digits than appropriate for the number.  More often than not,
>> this is a KIND error.
>>
> 
> Does the above issue warnings for
> 
>   real(knd), parameter :: pi = 3.1415926535897932384626433832795029_knd
> 
> module foomod
> 
>   interface foo
>      module procedure foo4, foo8, foo10, foo16
>   end interface foo
> 
>   contains
> 
>   subroutine foo4()
>   integer, parameter :: knd = 4
>   include 'consts.def'
>   ! do something with pi
>   end subroutine 
> end module foomod

Yes, it does, if -Wconversion-extra is specified.

> If warnings occur, then IMHO the patch cannot be committed
> in its current form.

What would be the peferred alternative?

I can make this warning conditional on a new option, let's call it
-Wconversion-constant, and have this set by default by -Wsurprising
or by -Wconversion.  The new options machinery is nice enough to
specify the option name with the warning, so it is easy for a user
to turn this particular warning off.

It would also be possible to grade this warning for really fine-grained
control:

- Introduce -Wconversion-constant, enabled by -Wconversion, to warn
  about the most common error of a constant with excess precision
  without KIND, so print *,3.1415829535 would get a warning and
  print *,3.1415926535_4 would not.

- Introduce -Wconversion-constant-extra, enabled by -Wconversion-extra,
  to warn about any excess precision regardless whether a KIND number
  is present in the constant or not.

Comments?

	Thomas

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

* Re: [patch, fortran] PR 47359 - warnings for constant conversion
  2015-06-01  6:34   ` [patch, fortran] PR 47359 - warnings for constant conversion Thomas Koenig
@ 2015-06-01 13:40     ` Steve Kargl
  2015-06-01 18:02       ` Thomas Koenig
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Kargl @ 2015-06-01 13:40 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Mon, Jun 01, 2015 at 08:34:24AM +0200, Thomas Koenig wrote:
> 
> >> The second part catches the case when the user supplies more
> >> digits than appropriate for the number.  More often than not,
> >> this is a KIND error.
> >>
> > 
> > Does the above issue warnings for
> > 
> >   real(knd), parameter :: pi = 3.1415926535897932384626433832795029_knd
> > 
> > module foomod
> > 
> >   interface foo
> >      module procedure foo4, foo8, foo10, foo16
> >   end interface foo
> > 
> >   contains
> > 
> >   subroutine foo4()
> >   integer, parameter :: knd = 4
> >   include 'consts.def'
> >   ! do something with pi
> >   end subroutine 
> > end module foomod
> 
> Yes, it does, if -Wconversion-extra is specified.
> 
> > If warnings occur, then IMHO the patch cannot be committed
> > in its current form.
> 
> What would be the peferred alternative?
> 

Is it possible to detect the _knd suffix?  If so, no
warning is my preference as it is never incorrect to
specify more digits than required for conversion from
ASCII to an internal representation.  This, of course,
assumes that the compiler doesn't have a bug.

> 
> Comments?
> 

I'm not a big fan of a proliferation of options.  As long
as the warning isn't triggered under -Wall, I suppose
I can live with -Wconversion-extra.

-- 
Steve

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

* Re: [patch, fortran] PR 47359 - warnings for constant conversion
  2015-06-01 13:40     ` Steve Kargl
@ 2015-06-01 18:02       ` Thomas Koenig
  2015-06-01 20:10         ` Steve Kargl
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Koenig @ 2015-06-01 18:02 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

Am 01.06.2015 um 15:40 schrieb Steve Kargl:
> On Mon, Jun 01, 2015 at 08:34:24AM +0200, Thomas Koenig wrote:
>> What would be the peferred alternative?

> Is it possible to detect the _knd suffix?

Yes, this is possible.

> If so, no
> warning is my preference as it is never incorrect to
> specify more digits than required for conversion from
> ASCII to an internal representation.  This, of course,
> assumes that the compiler doesn't have a bug.

:-)

>> > 
>> > Comments?
>> > 
> I'm not a big fan of a proliferation of options.  As long
> as the warning isn't triggered under -Wall, I suppose
> I can live with -Wconversion-extra.

OK, so we have a few options.

a) Warn for

  print *,3.1415926535897932 with -Wconversion

  and warn for

  print *,3.1415926535_4 only with -Wconversion-extra

b) Like a) but supply two options to switch off the respective
    warnings.

c) Warn for

  print *,3.1415926535 with -Wconversoin-extra

  and don't warn for

  print *,3.141592653589_4

d) Like now: Warn with -Wconversion-extra for both

   print *,3.1415926535

   and

   print *,3.14159265358979_4

What are people's prefrences on this?  Should we maybe ask on c.l.f
(where we will get more opinions, certainly also differing)?

	Thomas

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

* Re: [patch, fortran] PR 47359 - warnings for constant conversion
  2015-06-01 18:02       ` Thomas Koenig
@ 2015-06-01 20:10         ` Steve Kargl
  2015-06-06 11:35           ` Thomas Koenig
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Kargl @ 2015-06-01 20:10 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Mon, Jun 01, 2015 at 08:01:53PM +0200, Thomas Koenig wrote:
> Am 01.06.2015 um 15:40 schrieb Steve Kargl:
> > On Mon, Jun 01, 2015 at 08:34:24AM +0200, Thomas Koenig wrote:
> >> What would be the peferred alternative?
> 
> > Is it possible to detect the _knd suffix?
> 
> Yes, this is possible.
> 
> > If so, no
> > warning is my preference as it is never incorrect to
> > specify more digits than required for conversion from
> > ASCII to an internal representation.  This, of course,
> > assumes that the compiler doesn't have a bug.
> 
> :-)
> 
> >> > 
> >> > Comments?
> >> > 
> > I'm not a big fan of a proliferation of options.  As long
> > as the warning isn't triggered under -Wall, I suppose
> > I can live with -Wconversion-extra.
> 
> OK, so we have a few options.
> 
> a) Warn for
> 
>   print *,3.1415926535897932 with -Wconversion
> 
>   and warn for
> 
>   print *,3.1415926535_4 only with -Wconversion-extra
> 
> b) Like a) but supply two options to switch off the respective
>     warnings.
> 
> c) Warn for
> 
>   print *,3.1415926535 with -Wconversion-extra
> 
>   and don't warn for
> 
>   print *,3.141592653589_4
> 

This would be my first choice.  If a user actually specifies
a suffix, I assume that the user has given some thought 
to the preceding digits.

> d) Like now: Warn with -Wconversion-extra for both
> 
>    print *,3.1415926535
> 
>    and
> 
>    print *,3.14159265358979_4

This would be my second choice.

> What are people's prefrences on this?  Should we maybe ask on c.l.f
> (where we will get more opinions, certainly also differing)?

If you ask on c.l.f, you'll get differing opinions and most likely
a history lesson on what compilers did 40 years ago and how
PL/1 hands the issue. :-)

Don't let my person opinion be the sole driver/impediment.  
I do have a few comments on the patch itself.  I'll send those
later.

-- 
Steve

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

* Re: [patch, fortran] PR 47359 - warnings for constant conversion
  2015-06-01 20:10         ` Steve Kargl
@ 2015-06-06 11:35           ` Thomas Koenig
  2015-06-06 18:52             ` Steve Kargl
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Koenig @ 2015-06-06 11:35 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

Am 01.06.2015 um 22:10 schrieb Steve Kargl:

>> c) Warn for
>>
>>   print *,3.1415926535 with -Wconversion-extra
>>
>>   and don't warn for
>>
>>   print *,3.141592653589_4
>>
> 
> This would be my first choice.  If a user actually specifies
> a suffix, I assume that the user has given some thought 
> to the preceding digits.


>> d) Like now: Warn with -Wconversion-extra for both
>>
>>    print *,3.1415926535
>>
>>    and
>>
>>    print *,3.14159265358979_4
> 
> This would be my second choice.

I would actually prefer d).  -Wconversion-extra is about warning
for things that are often correct.  I would like to have a chance
to warn about this kind of construct.

Any other comments?  OK to commit?

	Thomas

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

* Re: [patch, fortran] PR 47359 - warnings for constant conversion
  2015-06-06 11:35           ` Thomas Koenig
@ 2015-06-06 18:52             ` Steve Kargl
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Kargl @ 2015-06-06 18:52 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Sat, Jun 06, 2015 at 12:22:56PM +0200, Thomas Koenig wrote:
> 
> Any other comments?  OK to commit?
> 

No. Yes.

-- 
Steve

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

end of thread, other threads:[~2015-06-06 14:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <556B7ED1.4020304@netcologne.de>
     [not found] ` <20150531221425.GA34602@troutmask.apl.washington.edu>
2015-06-01  6:34   ` [patch, fortran] PR 47359 - warnings for constant conversion Thomas Koenig
2015-06-01 13:40     ` Steve Kargl
2015-06-01 18:02       ` Thomas Koenig
2015-06-01 20:10         ` Steve Kargl
2015-06-06 11:35           ` Thomas Koenig
2015-06-06 18:52             ` Steve Kargl

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