Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: Increment (Was Re: Pascal deficiency)? Message-ID: <47610@apple.Apple.COM> Date: 28 Dec 90 00:45:49 GMT References: <33019.27737F47@stjhmc.fidonet.org> <47576@apple.Apple.COM> <1530@carol.fwi.uva.nl> Organization: Apple Computer Inc., Cupertino, CA Lines: 31 In article <1530@carol.fwi.uva.nl> freek@fwi.uva.nl (Freek Wiedijk) writes: >keith@Apple.COM (Keith Rollin) writes: >> Another interesting thing is that empty() is >>reduced to a simple RTS. Should an optimizing compiler recognize >>that this is a null procedure, and remove the call to it altogether? > >What happens if you declare empty static and compile the program with the >flag -finline-functions? I do not have gcc for MPW, so I cannot try it >myself. I am very curious what will be left. Pretty slick! The program: static void empty(int i) {}; main() { int i = 1; empty(++i); }; reduces to: Module: Flags=$00=(Local Code) Module="main%"(1) Segment="Main"(2) 00000000: 4E56 0000 'NV..' LINK A6,#$0000 00000004: 4E5E 'N^' UNLK A6 00000006: 4E75 'Nu' RTS Now...I wonder why the LINK/UNLK are still there. I also used -mbg off, so it's not for debugging purposes... -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions