# How can I eliminate this compilation warning? Warning: BINARY CREATED: binary is used

**URL:** <https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034>\
**Category:** Questions / Help\
**Tags:** erlang, erlang-otp\
**Created:** [November 16, 2023, 11:47am UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034 "2023-11-16T11:47:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmm](https://erlangforums.com/user_avatar/erlangforums.com/emmm/32/2051_2.png) [@emmm](https://erlangforums.com/u/emmm)\
**Post date:** [November 16, 2023, 11:47am UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034/1 "2023-11-16T11:47:37Z")

</div>

Hi!  
How can I eliminate this compilation warning?  
like this:  
mgr.erl:285: Warning: BINARY CREATED: binary is used in call to base64:decode/1 which doesn’t support context reuse  
% 285| Lev = util:to\_integer(base64:decode(Other)),

mgr.erl:285: Warning: NOT OPTIMIZED: binary is used in remote call to base64:decode/1  
% 285| Lev = util:to\_integer(base64:decode(Other)),

code:

 ![image](https://erlangforums.com/uploads/default/original/2X/0/0963de413fa37fec7bf065e6cec7916f3bb189a5.png)

---

<div class="post-metadata">

**Author:** ![starbelly](https://erlangforums.com/user_avatar/erlangforums.com/starbelly/32/209_2.png) [@starbelly](https://erlangforums.com/u/starbelly)\
**Post date:** [November 16, 2023, 12:08pm UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034/2 "2023-11-16T12:08:06Z")

</div>

Question about your question : Are you asking how to simply get rid of the warning or how to optimize the code to get rid of the warning?

---

<div class="post-metadata">

**Author:** ![emmm](https://erlangforums.com/user_avatar/erlangforums.com/emmm/32/2051_2.png) [@emmm](https://erlangforums.com/u/emmm)\
**Post date:** [November 16, 2023, 12:26pm UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034/3 "2023-11-16T12:26:06Z")

</div>

Sorry, I didn’t make it clear, I want to eliminate the warning by optimizing this code

---

<div class="post-metadata">

**Author:** ![starbelly](https://erlangforums.com/user_avatar/erlangforums.com/starbelly/32/209_2.png) [@starbelly](https://erlangforums.com/u/starbelly)\
**Post date:** [November 16, 2023, 1:40pm UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034/4 "2023-11-16T13:40:49Z")

</div>

You can not optimize this code, as far re-using the match context. The compiler is warning that it can not optimize for a match context reuse because of a remote call being made (`base64:decode/1`), it simply will not work, and that’s how it works, as of now. That is to say match context reuse is limited to local calls. Kindly pinging @garazdawi to validate that statement.

Likewise, you can not inline base64:decode/1 (as of now) to optimize that way, and even if you could, it may not be worth it anyway.

Now, on line 203, you could use `decode_to_string/1` since you’re going to make a sub-binary anyway per your match on line 204. You would of course have to benchmark to see if that is worth doing.

From the docs :

> Notice that the bin\_opt\_info is not meant to be a permanent option added to your Makefiles, because all messages that it generates cannot be eliminated. Therefore, passing the option through the environment is in most cases the most practical approach.

---

<div class="post-metadata">

**Author:** ![bjorng](https://erlangforums.com/user_avatar/erlangforums.com/bjorng/32/174_2.png) [@bjorng](https://erlangforums.com/u/bjorng)\
**Post date:** [November 17, 2023, 5:35am UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034/5 "2023-11-17T05:35:42Z")

</div>

> [@starbelly](#):
>
> You can not optimize this code, as far re-using the match context. The compiler is warning that it can not optimize for a match context reuse because of a remote call being made (`base64:decode/1`), it simply will not work, and that’s how it works, as of now. That is to say match context reuse is limited to local calls.

Yes.

I can also add that the binary that is created is **not** a complete copy the `Other` binary, but a sub binary, which is a small term that references part of the binary returned by `base64:decode/1`. Creating a sub binary is a very fast operation.

---

<div class="post-metadata">

**Author:** ![emmm](https://erlangforums.com/user_avatar/erlangforums.com/emmm/32/2051_2.png) [@emmm](https://erlangforums.com/u/emmm)\
**Post date:** [November 17, 2023, 6:43am UTC](https://erlangforums.com/t/how-can-i-eliminate-this-compilation-warning-warning-binary-created-binary-is-used/3034/6 "2023-11-17T06:43:53Z")

</div>

Thanks! I read the documentation and until then I thought there was something wrong with my code. 😇 😇 😇
