Bug 58795 - Specific versions of elemental functions (e.g. sin, dcos) are not pure
Summary: Specific versions of elemental functions (e.g. sin, dcos) are not pure
Status: RESOLVED DUPLICATE of bug 58676
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.3
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-18 19:53 UTC by Sean Santos
Modified: 2013-10-19 06:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Santos 2013-10-18 19:53:21 UTC
The Fortran standard doesn't really specify what's going on here, so I've marked this as an "enhancement", but it could be a helpful change.

In the attached program, the "eval" function can't run on the specific version of the intrinsic sin function because it's not pure, but it can run on a user-defined pure function that's nothing more than a wrapper for the elemental intrinsic. This was a mild annoyance when I was writing some "functional" tools (e.g. integration routines that take a user-defined function) and tried to test on the intrinsic sin/cos.

If the specific intrinsics were made pure, that would fix the issue. This could break backwards compatibility for programs that do this:

intrinsic :: sin
procedure(sin) :: f

That would be a problem if the author didn't want to give "f" the "pure" attribute. However, I doubt that there are many programs that try to use the intrinsics to avoid writing their own interface blocks.

For any other situation I can think of, adding "pure" to the specific intrinsics can only be a benefit.
Comment 1 kargls 2013-10-18 20:47:56 UTC
There isn't an attached example.  But, the Fortran standard states

F2008:p. 315
All standard intrinsic functions are pure.

It isn't at all clear what you mean.  I do note that the standard
further states

F2008: p. 315
If an intrinsic procedure is used as an actual argument to a procedure,
its specific name shall be used and it may be referenced in the called
procedure only with scalar arguments.
Comment 2 Tobias Burnus 2013-10-19 05:43:04 UTC
Isn't this PR the same as PR58676 and - related - PR58099 (esp. PR58099 comment 18)?
Comment 3 Sean Santos 2013-10-19 06:32:36 UTC
That's what I get for trying to rush through the report before leaving on Friday. This is indeed a duplicate of PR58676, and my missing attachment was essentially the same as the test case there.
Comment 4 Sean Santos 2013-10-19 06:33:37 UTC
Marking duplicate.

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