This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: __builtin_return_address why const parameter ?


Ulrich Lauther <ulrich.lauther@mchp.siemens.de> writes:

|> why am I forced to write clumsy code like this:
|> 
|>   void* bra = 0;
|>   switch (level) {
|>     case 1: bra = __builtin_return_address(1); break;
|>     case 2: bra = __builtin_return_address(2); break;
|>     case 3: bra = __builtin_return_address(3); break;
|>     case 4: bra = __builtin_return_address(4); break;
|>     default: ;
|>   }
|>   return bra;
|> 
|> 
|> instead of:
|> 
|>      return __builtin_return_address(level);
|> 
|> in other words, why does __builtin_return_address() insist on a 
|> integer constant as parameter?

Because __builtin_return_address is expanded at compile time.  Please also
note that __builtin_return_address will fail for non-zero arguments on
some machines.  The use with a non-zero argument is intented only for
debugging purpose.

Andreas.

-- 
Andreas Schwab                                  "And now for something
schwab@suse.de                                   completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]