public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Complex log builtins
@ 2004-08-29 15:47 Paul Brook
  2004-08-29 18:07 ` Gabriel Dos Reis
  2004-08-30  2:41 ` Kaveh R. Ghazi
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Brook @ 2004-08-29 15:47 UTC (permalink / raw)
  To: gcc; +Cc: ghazi

I just tried to make gfortran use the _Complex log builtins (clog, etc.), and 
discovered they don't exist.

The original post adding the other C99 math functions
(http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00180.html)
Mentions conflicts with C++ iostreams clog.

However since these are C99 builtins they don't get enabled for C++ (right?). 
I enabled the builtins and tried various combinations of clog, 
std::clog, ::clog and using namespace std; and couldn't trigger any bad 
behaviour. The C99 clog was uniformly ignored.

Can these builtins (clog, clogf and clogl) be enabled?

Paul

P.S. If we do enable clog, we probably want to add clog10 as well.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complex log builtins
  2004-08-29 15:47 Complex log builtins Paul Brook
@ 2004-08-29 18:07 ` Gabriel Dos Reis
  2004-08-30  2:41 ` Kaveh R. Ghazi
  1 sibling, 0 replies; 6+ messages in thread
From: Gabriel Dos Reis @ 2004-08-29 18:07 UTC (permalink / raw)
  To: Paul Brook; +Cc: gcc, ghazi

Paul Brook <paul@codesourcery.com> writes:

| I just tried to make gfortran use the _Complex log builtins (clog, etc.), and 
| discovered they don't exist.
| 
| The original post adding the other C99 math functions
| (http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00180.html)
| Mentions conflicts with C++ iostreams clog.
| 
| However since these are C99 builtins they don't get enabled for C++ (right?). 
Only under some circumstances, they are not enabled for C++.  As a matter
of fact, some people wants them unconditionally, others don't.  The
comprise was to have a switch that turns them on/off.  But you can't assume
they're never enabled.

| I enabled the builtins and tried various combinations of clog, 
| std::clog, ::clog and using namespace std; and couldn't trigger any bad 
| behaviour. The C99 clog was uniformly ignored.

Could you post your testing programs?

| Can these builtins (clog, clogf and clogl) be enabled?

As discussed with Joseph S. Myers in another thread, what we should do
is to put GCC built-ins in a GCC name space, say "__gcc_".  The reason
is that those are used by the middle-end which is language indendent
and should not dump C name space rules onto other languages.  But, as
I understand it, we should coordinate these with Glibc people -- and I
remember Benjamin offering to look into this if I send him examples.

-- Gaby

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complex log builtins
  2004-08-29 15:47 Complex log builtins Paul Brook
  2004-08-29 18:07 ` Gabriel Dos Reis
@ 2004-08-30  2:41 ` Kaveh R. Ghazi
  2004-08-30  3:10   ` Gabriel Dos Reis
  1 sibling, 1 reply; 6+ messages in thread
From: Kaveh R. Ghazi @ 2004-08-30  2:41 UTC (permalink / raw)
  To: paul; +Cc: gcc

 > I just tried to make gfortran use the _Complex log builtins (clog,
 > etc.), and discovered they don't exist.
 > 
 > The original post adding the other C99 math functions
 > (http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00180.html)
 > Mentions conflicts with C++ iostreams clog.
 > 
 > [...]
 > I enabled the builtins and tried various combinations of clog,
 > std::clog, ::clog and using namespace std; and couldn't trigger any
 > bad behaviour. The C99 clog was uniformly ignored.

I don't recall the exact failure I got, but it would have probably
been something exposed during a testsuite run.  Not sure if it was the
G++ or the libstdc++ testsuite.

If running those with the clog* builtins enabled doesn't break
something, it may just be that the compiler is different enough that
it's not longer a problem.  E.g. the new parser or builtins work may
have safely compartmentalized things.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complex log builtins
  2004-08-30  2:41 ` Kaveh R. Ghazi
@ 2004-08-30  3:10   ` Gabriel Dos Reis
  2004-08-30 14:33     ` Paul Brook
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel Dos Reis @ 2004-08-30  3:10 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: paul, gcc

"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:

[...]

| If running those with the clog* builtins enabled doesn't break
| something, it may just be that the compiler is different enough that
| it's not longer a problem.  E.g. the new parser or builtins work may
| have safely compartmentalized things.

Assuming C99's clog is enabled, I don't know how the compiler managed
to safely compartmentalize this: 

   #include <math.h>    // bring in C99's stuff
   #include <iostream>  // bring in C++ streams

   int main()
   {
      using namespace std;
      clog << "Hellow, World\n";
   } 

I can think of some library hacks attempting to make that work -in the
small-, but they're brittle hacks. 

-- Gaby

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complex log builtins
  2004-08-30  3:10   ` Gabriel Dos Reis
@ 2004-08-30 14:33     ` Paul Brook
  2004-08-30 15:29       ` Kaveh R. Ghazi
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Brook @ 2004-08-30 14:33 UTC (permalink / raw)
  To: gcc; +Cc: Gabriel Dos Reis, Kaveh R. Ghazi

On Monday 30 August 2004 04:00, Gabriel Dos Reis wrote:
> "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
>
> [...]
>
> | If running those with the clog* builtins enabled doesn't break
> | something, it may just be that the compiler is different enough that
> | it's not longer a problem.  E.g. the new parser or builtins work may
> | have safely compartmentalized things.
>
> Assuming C99's clog is enabled, I don't know how the compiler managed
> to safely compartmentalize this:
>
>    #include <math.h>    // bring in C99's stuff
>    #include <iostream>  // bring in C++ streams
>
>    int main()
>    {
>       using namespace std;
>       clog << "Hellow, World\n";
>    }

The above testcase works with the builtins enabled. Adding a call to 
__builtin_clog to the body of main() also works.

Note that the C99 clog is declared in <complex.h>, not <math.h>.
Adding #include <compex.h> to the above test still works correctly because g++ 
overrides complex.h with a header that just does #include <complex>

Adding #include "/usr/include/complex.h" forces an explicit definition of 
clog, and does break the program.

In summary enabling the builtins doesn't seem to break anything, though I'm 
not sure why.

Does this help any?

Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complex log builtins
  2004-08-30 14:33     ` Paul Brook
@ 2004-08-30 15:29       ` Kaveh R. Ghazi
  0 siblings, 0 replies; 6+ messages in thread
From: Kaveh R. Ghazi @ 2004-08-30 15:29 UTC (permalink / raw)
  To: paul; +Cc: gcc, gdr

 > The above testcase works with the builtins enabled. Adding a call to
 > __builtin_clog to the body of main() also works.
 > 
 > Note that the C99 clog is declared in <complex.h>, not <math.h>.
 > Adding #include <compex.h> to the above test still works correctly
 > because g++ overrides complex.h with a header that just does #include
 > <complex>
 > 
 > Adding #include "/usr/include/complex.h" forces an explicit definition
 > of clog, and does break the program.
 > 
 > In summary enabling the builtins doesn't seem to break anything,
 > though I'm not sure why.
 > 
 > Does this help any?
 > Paul

I really don't remember how it broke for me, have you tried running
the G++/libstdc++ testsuites with the builtins enabled?

Actually I'm not sure you need to worry about this.  Ultimately if
clog turns out still to be a conflict, you can activate just the
__builtin_clog style and leave clog out by using DEF_GCC_BUILTIN.  I
suspect that's all you need to get the middle-end machinery hooked up
with fortran.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-30 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-29 15:47 Complex log builtins Paul Brook
2004-08-29 18:07 ` Gabriel Dos Reis
2004-08-30  2:41 ` Kaveh R. Ghazi
2004-08-30  3:10   ` Gabriel Dos Reis
2004-08-30 14:33     ` Paul Brook
2004-08-30 15:29       ` Kaveh R. Ghazi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).