This code executes normally in VS2014, despite the fact that an inline member function is not defined in every TU in which it is odr-used.

Consider this code:
header.h:
#include <iostream>
class A{
int i;
public:
A() : i(101) {}
void print();
void g(A&);
cpp1:
#include "header.h"
inline void A::print() { std::cout << i << '\n'; }
int main()
A a;
a.print();
g(a);
cpp2:
#include "header.h"
void g(A& a) { a.print(); }
Note that the member function A::print is defined outside its class with the specifier inline. The code executes normally in VS2014, despite the fact that the member function is odr-used in cpp2, but it is not defined in this file.
I found the following quotes from the C++11 Standard:
9.3/3:
An inline member function (whether static or non-static) may also be defined outside of its class definition provided either its declaration in the class definition or its definition outside of the class definition declares the function as inline.
3.2/3:
An inline function shall be defined in every translation unit in which it is odr-used.
7.1.2/4:
An inline function shall be defined in every translation unit in which it is odr-used and shall have exactly the same definition in every case.
The two last quotes above don't speak exactly about a member function but I believe they should be applied in this case too, as the inline specifier is a hint for the compiler to expand the function inline at the point of call. If we assume the compiler
does this inline expansion, how does it know the definition of the member function, while compiling the cpp2 file?  

On 12/31/2014 12:13 PM, Belloc wrote:
C++ is supported on many different systems, with tools provided by many different vendors. Microsoft's linker happens to be pretty smart about merging identical blocks of code. Other toolchains may use linkers that weren't designed with this in mind,
and that would choke on multiple definitions of the same symbol. The C++ standard is written so that it's actually implementable, on as many platforms as possible.
Frankly I don't understand your statement above. What would be the difficulty for any compiler*that is already compliant with 3.2/3 and 7.1.2/4*, to adapt its code, so that each call to an inline function in a TU, which doesn't carry the function
definition, is simply not inlined?
That's the easy part. The "there's identical function definition in every .obj file, and the linker is expected to merge them all together" is the hard part. Normally, if you define a regular (non-inline) function in more than one source
file, you get a linker error. Microsoft's linker has a special way to mark "defined more than once, just pick any copy" block of code (see __declspec(selectany) ). Other linkers may not.
Igor Tandetnik

Similar Messages

  • EEM not start despite the fact that response of the track is down

    Hello all,
    I am trying to configure an EEM which shutdown and interface when the track is down but i remark that the action of EEM not start despite that every seem good. Here is the config :
    ip sla 5
    icmp-echo 8.8.8.8
    timeout 20000
    threshold 15000
    frequency 25
    ip sla schedule 5 life forever start-time now
    track 1 ip sla 5
    event manager applet SET-DOWN-INTERFACE
    event track 1 state down
    action 1.0 cli command "enable"
    action 1.1 cli command "conf t"
    action 1.2 cli command "int fastethernet 0/0"
    action 1.3 cli command "shutdown"
    action 1.4 cli command "end"
    action 1.5 cli command "exit"
    SHow command :
    #sh ip sla statisti
    IPSLA operation id: 5
    Type of operation: icmp-echo
            Latest RTT: NoConnection/Busy/Timeout
    Latest operation start time: *14:07:36.962 UTC Thu Nov 17 2011
    Latest operation return code: Timeout
    Number of successes: 0
    Number of failures: 6
    Operation time to live: Forever
    #sh track brief
    Track   Object                           Parameter        Value      Last Change
    1            ip sla      5                    state            Down       01:09:39
    Despite the fact that everything is down, EEM does not execute. Who can help me ?
    Thanks in advance.

    Hi  Smitesh,
    How can I configure the eem to checked state of two track before performing an action.
    the State of the two track must be down or UP for example that it execute action
    If i take my config above :
    ip sla 5
    icmp-echo 8.8.8.8
    timeout 20000
    threshold 15000
    frequency 25
    ip sla schedule 5 life forever start-time now
    ip sla 5
    icmp-echo 8.8.8.8
    timeout 20000
    threshold 15000
    frequency 25
    ip sla schedule 5 life forever start-time now
    ip sla 10
    icmp-echo 4.4.4.4
    timeout 20000
    threshold 15000
    frequency 25
    ip sla schedule 5 life forever start-time now
    track 1 ip sla 5
    track 2 ip sla 10
    How configure the event manager to doconfigure an interface only when the state of this two track is down or UP
    event manager applet SET-DOWN-INTERFACE
    Best Regards

  • TS4162 I have been able to upload videos to vimeo from FCPX in the past. However, now FC gives me a message that my password is incorrect. This is despite the fact that my password allows me to sign into the Vimeo website. Any ideas?

    I have been able to upload videos to vimeo from FCPX in the past. However, now FC gives me a message that my password is incorrect. This is despite the fact that my password allows me to sign into the Vimeo website. I have reset my vimeo password, restarted final cut and restarted my computer. Any ideas?

    Log in to Vimeo and change your password on the Vimeo site. Then update your FCPX settings for Vimeo to reflect the new password.
    I think Vimeo required this in light of the Heartbleed hack.

  • When i open my Canon RAW-files with preview or transfer them to another program using preview they change to color despite the fact that they where all shot in B/W... How to change this?

    When i open my Canon RAW-files with preview or transfer them to another program using preview they change to color despite the fact that they where all shot in B/W... How to change this?

    I shoot only RAW - no JPEG-files except those visualizing the files on my memorycard or computer. I think i have to refine my question;
    1. I know there is possible to make B/W HDR-images.
    2. I know the best HDR images are based on RAW-files.
    3. When i transfer the images in question to a HDR software they change, so when i view them in the software (either Preview or the HDR software) they are suddenly viewed (and processed) in color.
    4. This never happend on my PC so i know it has to do  with either Finder or Preview.
    5. Do i have to make all my B/W HDR-images on the PC or is it a way for me to change how Finder/Preview show/alter my images?

  • W3c valid site, initially no error reported by developer toolbar. But upon right click (giving the validation menue), the the toolbar reports two errors: width and height. Despite the fact that every page is validated! On the forum for the toolbar, this i

    w3c valid site, initially no error reported by developer toolbar. But upon right click (giving the validation menue), the the toolbar reports two errors: width and height. Despite the fact that every page is validated! On the forum for the toolbar, this is said to be a Browser error. So, how can this be fixed? I'm using FF 3.6.6
    == This happened ==
    Every time Firefox opened
    == after update from 3.5?

    Hi Sara,
    Can you give us the URL of the page you're having problems with and of the forum thread you mentioned?
    Thanks!

  • My trial is about to expire despite the fact that I have a Creative Cloud subscription

    Since installing the beta I get a message saying my trial is about to expire despite the fact that I have a Creative Cloud subscription. Also I have two Adobe IDs and despite trying to change the default it keeps switching back to the one that doesn't have the CC sub. Also in About Muse it says I am on v3.1 Build 8, is this correct?

    Any help on this from Muse staff would be appreciated

  • I frequently receive a notice from Mail that it "can't connect" to my yahoo mail account, despite the fact that I can receive mail from that account. The banner appears with my coded password highlighted and asks me to choose 'cancel' or 'ok'.

    I frequently receive a notice from Mail that it 'can't connect' to my Yahoo account despite the fact that I am able to receive mail from that account. It appears with the name of my Yahoo account, my password (coded), and the choice to 'cancel' or 'ok'. If I click either, the banner goes away but comes back soon. I can open Mail and see that all accounts are online. I get the banner SEVERAL time during a session - very annoying!
    I have several accounts, but this only happens with Yahoo and sometimes Hotmail. Can anyone tell me how to resolve this Mail issue?
    Thanks.

    I have 5 IMAP and 1 POP (Hotmail).
    The Yahoo is IMAP.

  • I've been paying for Adobe Premiere pro for the past Thre onth and today, despite the fact that i have paid already for the upcoming month, i cannot access it because of an "intenet connexion problem". But I'm connected and I have the right ID. What shoul

    I've been paying for Adobe Premiere pro for the past three month and today, despite the fact that i have paid already for the upcoming month, i cannot access it because of an "intenet connexion problem". But I'm connected and I have the right ID. What should I do?

    Lanakivee
    Try this it worked for me Pat Willener gave it to me off the site :
    I have not read all you wrote, so I may have missed some points. As I understand it, you installed FP 10 on IE7, but it won't play any Flash content?
    Try this
    download the FP uninstaller from http://www.adobe.com/go/tn_14157
    close all browser windows, then run the uninstaller
    download the offline ActivX installer for Internet Explorer from http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_ax.exe
    close all browser windows, then run the installer

  • 13" late 2011 MacBook Pro has frozen after Yosemite installation. I can, however, boot from a clone of my MacBook Air that is on an external drive. Despite the fact that I can boot from the external, could it be the RAM that's the prob

    My daughter's 13" late 2011 MacBook Pro has frozen (null sign displays) after Yosemite installation. I can, however, boot from a clone of my MacBook Air that is on an external drive. I reinstalled Yosemite on the MBP HD, but it still hangs in mid install. Despite the fact that I can boot from the external, could it be the RAM that's the problem? I'd happily put 8 GB in if it seems probable that would solve the problem. I've tried all the suggested procedures that I've seen posted here. Disk Utility, and my older version of DiskWarrior indicate the HD is OK. I have DiskWarrior 5 on order.

    Boot the MBP with the OPTION key down.  If successful, you should see two HDD icons,  Select the recovery partition (on the right).
    From the 4 option menu select Disk Utility.
    Run Disk Utility>First Aid, Verify and Repair.
    If the disk cannot be repaired, it will have to be replaced.
    Ciao.

  • When attempting to convert pdf to word doc, I continually get "An error occurred while signing in" despite the fact that I'm already signed in.  Please help if you can?

    When attempting to convert pdf to word doc, I continually get "An error occurred while signing in" despite the fact that I'm already signed in.  Please help if you can?

    Hi lorrelaws,
    Do you receive that error when you try to sign in via Reader? If so, try signing in via the web interface. Did that do the trick?
    Let us know how it goes.
    Best,
    Sara

  • IE showing Flash Player status disabled, despite the fact that it's enabled in Manage Add Ons.

    I uninstalled Flash Player version 13 on Windows 8 and then re-installed Flash Player version 11.7.700.275. After the successful installation message, I restarted the computer, but when I access the URL 'http://helpx.adobe.com/flash-player.html' it says, Your Flash version: Disabled. Despite the fact that IE is showing it enabled in Manage Add-Ons. Please help.

    Please ask your question on a forum for the Flash Player

  • I now have 5 off occurrences listed as being open despite the fact that they were all created on 2 off laptops, neither of which has now got itunes activated

    I now have 5 off occurrences of itunes listed as being open despite the fact that they were all created on 2 off laptops, neither of which has now got itunes activated. I now cannot activate itunes on either. The suggestion is that I cancel itnues activation on either which is rather difficult, obviously? Is there another way to access/ activate itunes?

    Now fixed by de-authorising computer online at Itunes store...

  • Firefox will not work on this computer despite the fact that it has worked fine for the last year...

    latest version has been added ... does not fire up...
    using windows 7 service pack 1

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • TS4062 When I try to sync my phone using WiFi, I get a message that "Sync will resume when "****PC" (a computer I used previously and no longer have) is available."  I cannot get past this.  It says my last sync was months ago, despite the fact that I hav

    When I try to sync my phone using WiFi, it will not sync and the following message is displayed: "Sync will resume when "*****" (my old computer I no longer have) is available."  I have synced several times on my new computer using the USB cable, but the message also gives the date of the last sync months ago, when I had the old computer. Any ideas?

    I know you can't help with my Yahoo problem, however, apparently at some time in the past I have went to the Sync and tried to figure it out on both my laptop and my desktop, because I have the long snyc key information. However, when I go to try to sync both computers I never get the box to enter that key on either one. That is my problem. So should I try and get a new sync key and see if that works.

  • My Library is missing despite the fact that I am logged in.

    I used to have 1500+ songs and now I have 2 albums, maybe totalling 20 songs.
    I do not want to lose everything on my iPod so I am afraid to sync and am therefore unable to add any new music. Any suggestions?

    You would have downloaded those apps with the wrong Apple ID then created a new Apple ID which is the on you are on now. This is acting as normal because all content downloaded from the iTunes and App Store is attached to the Apple ID it was downloaded with. To stop this you would delete the apps and redownload them with your current Apple ID you are signed in with.

Maybe you are looking for