CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Warning:no return statement in function returning non-void [-Wreturn-type] (https://www.cfd-online.com/Forums/openfoam-programming-development/233241-warning-no-return-statement-function-returning-non-void-wreturn-type.html)

3014214149 January 19, 2021 02:21

Warning:no return statement in function returning non-void [-Wreturn-type]
 
Hi, everyone,

I'm compiling a new lib in Of-4.1. I met a warning"no return statement in function returning non-void [-Wreturn-type]" when compiling. The warning occurred in my code file "imcompressibleTurbuleneModel.H" line 140.

The code is:

#ifndef incompressibleTurbulenceModel_H
#define incompressibleTurbulenceModel_H

#include "turbulenceModel.H"
#include "geometricOneField.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Forward declarations
class fvMesh;

/*---------------------------------------------------------------------------*\
Class incompressibleTurbulenceModel Declaration
\*---------------------------------------------------------------------------*/

class incompressibleTurbulenceModel
:
public turbulenceModel
{

protected:

// Protected data

geometricOneField rho_;


// Protected member functions

//- ***HGW Temporary function to be removed when the run-time selectable
// thermal transport layer is complete
virtual void correctNut()
{}


private:

// Private Member Functions

//- Disallow default bitwise copy construct
incompressibleTurbulenceModel(const incompressibleTurbulenceModel&);

//- Disallow default bitwise assignment
void operator=(const incompressibleTurbulenceModel&);


public:

//- Runtime type information
TypeName("incompressibleTurbulenceModel");


// Constructors

//- Construct from components
incompressibleTurbulenceModel
(
const geometricOneField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const word& propertiesName
);


//- Destructor
virtual ~incompressibleTurbulenceModel()
{}


// Member Functions

//- Return the laminar dynamic viscosity
virtual tmp<volScalarField> mu() const;

//- Return the laminar dynamic viscosity on patch
virtual tmp<scalarField> mu(const label patchi) const;

//- Return the turbulence dynamic viscosity
virtual tmp<volScalarField> mut() const;

//- Return the turbulence dynamic viscosity on patch
virtual tmp<scalarField> mut(const label patchi) const;

//- Return the effective dynamic viscosity
virtual tmp<volScalarField> muEff() const;

//- Return the effective dynamic viscosity on patch
virtual tmp<scalarField> muEff(const label patchi) const;

//- Return the effective stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devReff() const = 0;

//- Return the source term for the momentum equation
virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const = 0;

//- Return the source term for the momentum equation using NN surrogate
virtual tmp<fvVectorMatrix> divDevReff
(
volVectorField& U,
volTensorField& S,
volTensorField& R
) { } //line 140
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

Could anyone tell me how to resolve this warning? Many thanks!

lumpor January 19, 2021 11:40

The { } at line 140 is the function body, which is empty. The file is a header file, which means it usually only has function declarations and not function implementations (except for some trivial functions like get functions).


The functions expects the body to include a "return x" line, where x is of type virtual tmp<fvVectorMatrix>. Since the function body is empty, nothing is returned.


Most likely it's supposed to be a function declaration and not a function implementation. Replacing {} with ; should work.


All times are GMT -4. The time now is 09:17.