2017-07-11 18:30 GMT+02:00 Eli Zaretskii <eliz@gnu.org>:
> From: Fabrice Popineau <fabrice.popineau@gmail.com>
> Date: Tue, 11 Jul 2017 18:24:15 +0200
> Cc: Noam Postavsky <npostavs@users.sourceforge.net>, Emacs developers <emacs-devel@gnu.org>
>
>  If so, does it mean that after
>  invoking 'setenv', your process-environment has 2 members which both
>  start with "TEMP=", but have different values? Because _this_ is what
>  I cannot reproduce and frankly don't understand how could it happen.
>
> And now I understand the reason why you don't see the problem.
> I compile emacs from a mingw64 prompt. I have started emacs from the msys2 bash.
> This is what messes up the environment.

Can you tell the details of how it "messes up" the environment?

Bash implements a case sensitive environment :

Fabrice@LOBSANG 
$ export FOO=BAR

Fabrice@LOBSANG 
$ export foo=baz

Fabrice@LOBSANG 
$ echo $FOO
BAR

Fabrice@LOBSANG 
$ echo $foo
baz

Emacs is built as a mingw64 app, not an msys app. 
So it should behave as any native Windows app, wether you run it from bash or not.
At least, that is what I would expect.
So in this case, the environment variables should be considered case insensitive.
But emacs will inherit the env vars from bash, and arguably, they are case sensitive.

Another option is to make emacs inherit the variables from the desktop, not from the shell (or cmd) it is started from.
That would make sense at least for a GUI emacs. But that is less flexible.

Fabrice