Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 426
    • Issues 426
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #1638
Closed
Open
Issue created Mar 16, 2020 by Kutalmış Berçin@kutiMaintainer

BUG: Zero (complex) to the power of zero (label/scalar) does not follow Gcc/Clang

Summary

There is no agreed value for zero to the power of zero in C++ standard, but C99.

Despite this, Gcc and Clang implementations assume Type(0)^0 = 1.

In OpenFOAM, when Type=complex, the assumption is not followed even though Foam::pow is based on std::pow. When Type=scalar, the above assumption is followed.

Steps to reproduce

Test-A.tar.gz produces the following:

# FOAM: complex(0)^0 #
Foam::pow(Foam::complex, label) = (-nan -nan)
Foam::pow(Foam::complex, scalar) = (-nan -nan)
std::pow(std::complex, label) = (-nan -nan)
std::pow(std::complex, scalar) = (-nan -nan)

# std: complex(0)^0 #
std::complex(scalar,scalar)^scalar = (1,0)

# FOAM: scalar(0)^0 #
Foam::pow(scalar, label) = 1
Foam::pow(scalar, scalar) = 1

# std: scalar(0)^0 #
std::pow(scalar, label) = 1
std::pow(scalar, scalar) = 1

What is the expected correct behavior?

Foam::pow should return whatever std::pow returns for complex types.

Environment information

  • OpenFOAM version : dev
  • Operating system : osuse
  • Compiler : gcc 7
Edited Mar 16, 2020 by Kutalmış Berçin
Assignee
Assign to
Time tracking