# Scope the scope - unexpected function behaviour

**URL:** https://community.freefem.org/t/scope-the-scope-unexpected-function-behaviour/1298
**Category:** General Discussion
**Created:** [November 4, 2021, 4:25pm UTC](https://community.freefem.org/t/scope-the-scope-unexpected-function-behaviour/1298 "2021-11-04T16:25:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)
#### Post date: [November 4, 2021, 4:25pm UTC](https://community.freefem.org/t/scope-the-scope-unexpected-function-behaviour/1298/1 "2021-11-04T16:25:49Z")

</div>

Just out of curiosity, does anyone know that in the following script:

```auto

func real fun1(complex in1){
    
    cout << "in fun1: in1=" << in1 << endl;
    complex in12Scope = in1;
    
    func real fun2(complex in2){
        cout << "in fun2: in1=" << in1 << endl;
        cout << "in fun2: in12Scope=" << in12Scope << endl;
        return 0;
    }
    fun2(0);
    
    return 0;
}
fun1(alpha);

```

why does the line `cout << "in fun2: in1=" << in1 << endl;` write (0,0) as output?

---

<div class="post-metadata">

### Author: ![ivan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ivan/32/823_2.png) [@ivan](https://community.freefem.org/u/ivan)
#### Post date: [November 6, 2021, 7:40pm UTC](https://community.freefem.org/t/scope-the-scope-unexpected-function-behaviour/1298/2 "2021-11-06T19:40:00Z")

</div>

I can confirm this, for the script:

```cpp
complex alpha = 2 + 1i;
fun1(alpha);

```

and using the function given above, I get the following output:

```cpp
in fun1: in1=(2,1)
in fun2: in1=(0,0)
in fun2: in12Scope=(2,1)

```

Edit: FreeFem++ guide Version 3.48 does not contain the keyword scope in the index. With a search I could only find the sentence:

> The scope of a variable is the current block `{...}` like in C++…

So it looks like undefined behavior to me.
